serve 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +6 -0
- data/lib/serve.rb +22 -10
- data/lib/serve/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/lib/serve.rb
CHANGED
@@ -75,7 +75,9 @@ module Serve #:nodoc:
|
|
75
75
|
if layout
|
76
76
|
lines = IO.read(layout)
|
77
77
|
context = Context.new(Dir.pwd, @script_filename, engine.options.dup)
|
78
|
-
context.content = engine.render(context)
|
78
|
+
context.content = engine.render(context) do |*args|
|
79
|
+
context.get_content_for(*args)
|
80
|
+
end
|
79
81
|
layout_engine = Haml::Engine.new(lines, engine.options.dup)
|
80
82
|
layout_engine.render(context) do |*args|
|
81
83
|
context.get_content_for(*args)
|
@@ -130,35 +132,45 @@ module Serve #:nodoc:
|
|
130
132
|
|
131
133
|
def render(options)
|
132
134
|
partial = options.delete(:partial)
|
135
|
+
template = options.delete(:template)
|
133
136
|
case
|
134
137
|
when partial
|
135
138
|
render_partial(partial)
|
139
|
+
when template
|
140
|
+
render_template(template)
|
136
141
|
else
|
137
142
|
raise "render options not supported #{options.inspect}"
|
138
143
|
end
|
139
144
|
end
|
140
145
|
|
141
146
|
def render_partial(partial)
|
147
|
+
render_template(partial, :partial => true)
|
148
|
+
end
|
149
|
+
|
150
|
+
def render_template(template, options={})
|
142
151
|
path = File.dirname(@script_filename)
|
143
|
-
if
|
144
|
-
|
152
|
+
if template =~ %r{^/}
|
153
|
+
template = template[1..-1]
|
145
154
|
path = @root
|
146
155
|
end
|
147
|
-
filename =
|
156
|
+
filename = template_filename(File.join(path, template), :partial => options.delete(:partial))
|
148
157
|
if File.file?(filename)
|
149
158
|
lines = IO.read(filename)
|
150
159
|
engine = Haml::Engine.new(lines, @engine_options)
|
151
|
-
engine.render(self)
|
160
|
+
engine.render(self) do |*args|
|
161
|
+
get_content_for(*args)
|
162
|
+
end
|
152
163
|
else
|
153
164
|
raise "File does not exist #{filename.inspect}"
|
154
165
|
end
|
155
166
|
end
|
156
|
-
|
157
|
-
def
|
167
|
+
|
168
|
+
def template_filename(name, options)
|
158
169
|
path = File.dirname(name)
|
159
|
-
|
160
|
-
|
161
|
-
|
170
|
+
template = File.basename(name)
|
171
|
+
template = "_" + template if options.delete(:partial)
|
172
|
+
template += ".haml" unless name =~ /\.haml$/
|
173
|
+
File.join(path, template)
|
162
174
|
end
|
163
175
|
end
|
164
176
|
end
|
data/lib/serve/version.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: serve
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.9.
|
7
|
-
date: 2008-
|
6
|
+
version: 0.9.5
|
7
|
+
date: 2008-02-19 00:00:00 -05:00
|
8
8
|
summary: Serve is a small Ruby script that makes it easy to start up a WEBrick server in any directory. Serve is ideal for HTML prototyping and simple file sharing. If the haml, redcloth, and bluecloth gems are installed serve can handle Haml, Sass, Textile, and Markdown (in addition to HTML).
|
9
9
|
require_paths:
|
10
10
|
- lib
|
metadata.gz.sig
CHANGED
Binary file
|