mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
When rendering layouts with blocks, use #capture to avoid assuming that the return value is the block's content.
Signed-off-by: Yehuda Katz <wycats@Yehuda-Katz.local>
This commit is contained in:
committed by
Yehuda Katz
parent
cb9a1759c0
commit
cbded53671
@@ -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)
|
||||
|
||||
@@ -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 %>
|
||||
|
||||
Reference in New Issue
Block a user