Fix that locals are not passed to layout

Signed-off-by: Simon Rozet <simon@rozet.name>
This commit is contained in:
Michael Jones 2009-05-19 16:03:35 +02:00 committed by Ryan Tomayko
parent ce0fe87af3
commit 68d5dc1a76
2 changed files with 17 additions and 1 deletions

View File

@ -268,7 +268,7 @@ module Sinatra
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 File

@ -85,6 +85,22 @@ class TemplatesTest < Test::Unit::TestCase
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.