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 CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.9.5 (February 19, 2008)
2
+
3
+ * Added support for rendering other files with the following syntax:
4
+
5
+ render :template => "template_name"
6
+
1
7
  == 0.9.4 (January 31, 2008)
2
8
 
3
9
  * Small fix for calculating the partial name in render_partial.
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 partial =~ %r{^/}
144
- partial = partial[1..-1]
152
+ if template =~ %r{^/}
153
+ template = template[1..-1]
145
154
  path = @root
146
155
  end
147
- filename = partial_filename(File.join(path, partial))
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 partial_filename(name)
167
+
168
+ def template_filename(name, options)
158
169
  path = File.dirname(name)
159
- partial = File.basename(name)
160
- partial = "_" + partial + ".haml"
161
- File.join(path, partial)
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
@@ -2,7 +2,7 @@ module Serve #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
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.4
7
- date: 2008-01-31 00:00:00 -05:00
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