mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
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:
committed by
José Valim
parent
50c7aab996
commit
7846fb79e1
2
actionpack/test/fixtures/test/_partial_with_partial.erb
vendored
Normal file
2
actionpack/test/fixtures/test/_partial_with_partial.erb
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
<%= render 'test/partial' %>
|
||||
partial with partial
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user