Permalink
Browse files

Fix that locals are not passed to layout

Signed-off-by: Simon Rozet <simon@rozet.name>
  • Loading branch information...
1 parent ce0fe87 commit 68d5dc1a76f3bfedecca4fa93b069c4be868566c @mikejones mikejones committed with rtomayko May 19, 2009
Showing with 17 additions and 1 deletion.
  1. +1 −1 lib/sinatra/base.rb
  2. +16 −0 test/templates_test.rb
View
@@ -268,7 +268,7 @@ def render(engine, template, options={}, locals={})
if layout
data, options[:filename], options[:line] = lookup_layout(engine, layout, views)
if data
- output = __send__("render_#{engine}", layout, data, options, {}) { output }
+ output = __send__("render_#{engine}", layout, data, options, locals) { output }
end
end
View
@@ -85,6 +85,22 @@ def with_default_layout
assert @app.templates.empty?
end
+
+ it 'passes locals to the layout' do
+ mock_app {
+ template :my_layout do
+ 'Hello <%= name %>!<%= yield %>'
+ end
+
+ get '/' do
+ erb '<p>content</p>', { :layout => :my_layout }, { :name => 'Mike'}
+ end
+ }
+
+ get '/'
+ assert ok?
+ assert_equal 'Hello Mike!<p>content</p>', body
+ end
end
# __END__ : this is not the real end of the script.

0 comments on commit 68d5dc1

Please sign in to comment.