From b6166ffcb2af0df2045b32ced3ef6c591cc34d9b Mon Sep 17 00:00:00 2001 From: Anton Astashov Date: Sun, 5 Sep 2010 21:11:25 +0800 Subject: [PATCH 1/2] Added test for 'Layout with partial and yield' bug --- .../test/_layout_with_partial_and_yield.html.erb | 5 +++++ actionpack/test/template/render_test.rb | 5 +++++ 2 files changed, 10 insertions(+), 0 deletions(-) create mode 100644 actionpack/test/fixtures/test/_layout_with_partial_and_yield.html.erb diff --git a/actionpack/test/fixtures/test/_layout_with_partial_and_yield.html.erb b/actionpack/test/fixtures/test/_layout_with_partial_and_yield.html.erb new file mode 100644 index 0000000..e71d49a --- /dev/null +++ b/actionpack/test/fixtures/test/_layout_with_partial_and_yield.html.erb @@ -0,0 +1,5 @@ +Before +<%= render :partial => "test/partial.html.erb" %> +<%= yield %> +After + diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index c17bec8..f852237 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -189,6 +189,11 @@ module RenderTestCases @view.formats = nil end + def test_render_layout_with_block_and_other_partial_inside + render = @view.render(:layout => "test/layout_with_partial_and_yield.html.erb") { "Yield!" } + assert_equal "Before\npartial html\nYield!\nAfter", render + end + def test_render_inline assert_equal "Hello, World!", @view.render(:inline => "Hello, World!") end -- 1.7.2 From 4562cbf7bf73644b7d6347a36d4b00f9dac0730e Mon Sep 17 00:00:00 2001 From: Krekoten' Marjan Date: Sun, 5 Sep 2010 18:59:16 +0300 Subject: [PATCH 2/2] Fix 'yield' won't show block contents in render :layout, if it is placed after render :partial [#5557 state:resolved] --- actionpack/lib/action_view/render/partials.rb | 8 +------- .../test/_layout_with_partial_and_yield.html.erb | 3 +-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 92cdbfb..dd58f67 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -325,13 +325,7 @@ module ActionView end def _render_partial(options, &block) #:nodoc: - if defined?(@renderer) - @renderer.setup(options, block) - else - @renderer = PartialRenderer.new(self, options, block) - end - - @renderer.render + PartialRenderer.new(self, options, block).render end end diff --git a/actionpack/test/fixtures/test/_layout_with_partial_and_yield.html.erb b/actionpack/test/fixtures/test/_layout_with_partial_and_yield.html.erb index e71d49a..a6b9322 100644 --- a/actionpack/test/fixtures/test/_layout_with_partial_and_yield.html.erb +++ b/actionpack/test/fixtures/test/_layout_with_partial_and_yield.html.erb @@ -1,5 +1,4 @@ Before <%= render :partial => "test/partial.html.erb" %> <%= yield %> -After - +After \ No newline at end of file -- 1.7.2