Permalink
Browse files

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.
  • Loading branch information...
1 parent 50c7aab commit 7846fb79e1296986c41250bfea2e115e7683fa61 @carlosantoniodasilva carlosantoniodasilva committed with josevalim Nov 11, 2010
Showing with 12 additions and 0 deletions.
  1. +2 −0 actionpack/test/fixtures/test/_partial_with_partial.erb
  2. +10 −0 actionpack/test/template/render_test.rb
View
2 actionpack/test/fixtures/test/_partial_with_partial.erb
@@ -0,0 +1,2 @@
+<%= render 'test/partial' %>
+partial with partial
View
10 actionpack/test/template/render_test.rb
@@ -267,6 +267,16 @@ def test_render_layout_with_block_which_renders_another_partial_and_yields
@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")

0 comments on commit 7846fb7

Please sign in to comment.