mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Fix that locals are not passed to layout
Signed-off-by: Simon Rozet <simon@rozet.name>
This commit is contained in:
parent
ce0fe87af3
commit
68d5dc1a76
2 changed files with 17 additions and 1 deletions
|
@ -268,7 +268,7 @@ module Sinatra
|
||||||
if layout
|
if layout
|
||||||
data, options[:filename], options[:line] = lookup_layout(engine, layout, views)
|
data, options[:filename], options[:line] = lookup_layout(engine, layout, views)
|
||||||
if data
|
if data
|
||||||
output = __send__("render_#{engine}", layout, data, options, {}) { output }
|
output = __send__("render_#{engine}", layout, data, options, locals) { output }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,22 @@ class TemplatesTest < Test::Unit::TestCase
|
||||||
|
|
||||||
assert @app.templates.empty?
|
assert @app.templates.empty?
|
||||||
end
|
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
|
||||||
|
|
||||||
# __END__ : this is not the real end of the script.
|
# __END__ : this is not the real end of the script.
|
||||||
|
|
Loading…
Reference in a new issue