diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb index 4198013f57..4d35296932 100644 --- a/actionpack/lib/action_view/render/rendering.rb +++ b/actionpack/lib/action_view/render/rendering.rb @@ -56,7 +56,7 @@ module ActionView :identifier => template.identifier, :layout => layout.try(:virtual_path)) do content = template.render(self, locals) { |*name| _layout_for(*name) } - @_content_for[:layout] = content + @_content_for[:layout] = content if layout content = _render_layout(layout, locals) if layout content diff --git a/actionpack/test/fixtures/layouts/yield_with_render_inline_inside.erb b/actionpack/test/fixtures/layouts/yield_with_render_inline_inside.erb new file mode 100644 index 0000000000..7298d79690 --- /dev/null +++ b/actionpack/test/fixtures/layouts/yield_with_render_inline_inside.erb @@ -0,0 +1,2 @@ +<%= render :inline => 'welcome' %> +<%= yield %> diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index aca96e0a24..059dcedad8 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -229,6 +229,12 @@ module RenderTestCases @view.render(:file => "test/hello_world.erb", :layout => "layouts/yield") end + def test_render_with_layout_which_has_render_inline + assert_equal %(welcome\nHello world!\n), + @view.render(:file => "test/hello_world.erb", :layout => "layouts/yield_with_render_inline_inside") + end + + # TODO: Move to deprecated_tests.rb def test_render_with_nested_layout_deprecated assert_deprecated do