Fix render partial with layout and no block

When using a render :partial with :layout call, without giving a block,
if the given :partial had another render :partial call, the layout was
not being rendered. This commit fixes this context by storing variables
before rendering the partial, so they are not overrided in any successive
call to render partials down the path. All ActionPack tests are ok.
This commit is contained in:
Carlos Antonio da Silva
2010-11-11 11:08:17 -02:00
committed by José Valim
parent 50c7aab996
commit 7846fb79e1
2 changed files with 12 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
<%= render 'test/partial' %>
partial with partial

View File

@@ -267,6 +267,16 @@ module RenderTestCases
@view.render(:layout => "layouts/partial_and_yield") { "Content from block!" }
end
def test_render_partial_and_layout_without_block_with_locals
assert_equal %(Before (Foo!)\npartial html\nAfter),
@view.render(:partial => 'test/partial', :layout => 'test/layout_for_partial', :locals => { :name => 'Foo!'})
end
def test_render_partial_and_layout_without_block_with_locals_and_rendering_another_partial
assert_equal %(Before (Foo!)\npartial html\npartial with partial\n\nAfter),
@view.render(:partial => 'test/partial_with_partial', :layout => 'test/layout_for_partial', :locals => { :name => 'Foo!'})
end
def test_render_with_nested_layout
assert_equal %(<title>title</title>\n\n<div id="column">column</div>\n<div id="content">content</div>\n),
@view.render(:file => "test/nested_layout.erb", :layout => "layouts/yield")