aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_view/render/rendering.rb6
-rw-r--r--actionpack/test/fixtures/layouts/block_with_layout.erb2
2 files changed, 3 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb
index fc89726670..7006a5b968 100644
--- a/actionpack/lib/action_view/render/rendering.rb
+++ b/actionpack/lib/action_view/render/rendering.rb
@@ -71,12 +71,10 @@ module ActionView
# In this case, the layout would receive the block passed into <tt>render :layout</tt>,
# and the Struct specified in the layout would be passed into the block. The result
# would be <html>Hello David</html>.
- def _layout_for(name = nil)
+ def _layout_for(name = nil, &block)
return @_content_for[name || :layout] if !block_given? || name
- with_output_buffer do
- return yield
- end
+ capture(&block)
end
def _render_inline(inline, layout, options)
diff --git a/actionpack/test/fixtures/layouts/block_with_layout.erb b/actionpack/test/fixtures/layouts/block_with_layout.erb
index 6a8b41914b..f25b41271d 100644
--- a/actionpack/test/fixtures/layouts/block_with_layout.erb
+++ b/actionpack/test/fixtures/layouts/block_with_layout.erb
@@ -1,3 +1,3 @@
-<% render(:layout => "layout_for_partial", :locals => { :name => "Anthony" }) do %>Inside from first block in layout<% end %>
+<% render(:layout => "layout_for_partial", :locals => { :name => "Anthony" }) do %>Inside from first block in layout<% "Return value should be discarded" %><% end %>
<%= yield %>
<% render(:layout => "layout_for_partial", :locals => { :name => "Ramm" }) do %>Inside from second block in layout<% end %>