Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix that locals are not passed to layout

Signed-off-by: Simon Rozet <simon@rozet.name>
  • Loading branch information...
commit 68d5dc1a76f3bfedecca4fa93b069c4be868566c 1 parent ce0fe87
Michael Jones mikejones authored rtomayko committed
Showing with 17 additions and 1 deletion.
  1. +1 −1  lib/sinatra/base.rb
  2. +16 −0 test/templates_test.rb
2  lib/sinatra/base.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
16 test/templates_test.rb
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.
Please sign in to comment.
Something went wrong with that request. Please try again.