This project is archived and is in readonly mode.
render :layout with block and multiple yields renders twice
-
Jeff Schuil
Also, in _common.html.erb, if instead of <%= yield :top %> I use (the deprecated) <%= @content_for_top %> it works as expected.
-
Steve Madsen
- Tag changed from content_for, layout, render, yield to 2.3.5, content_for, layout, render, yield
I don't see a doubled "view", but I can confirm that I reproduced the "stack too deep" problem when rendering a complex template on 2.3.5. In my case, the template rendered a block with a layout, and inside the block, rendered a partial with a different layout, the whole thing wrapped in a normal layout. Yes, hairy. Inherited code, one of many things I'm trying to clean up.
Specifying "yield :layout" explicitly in every template that acts as a layout fixed the recursion that happens due to the render-block-with-layout code. The problem also goes away if I remove the render-block-with-layout (keeping the inner part), though in that case part of the page design goes away, so it's not a very good fix.
-
Leandro Pedroni
There's also a problem with passing a layout to render a collection with partials.
The layout is applied around the whole collection (as expected), but the whole thing (layout plus collection partials) gets rendered as many times as the items in the collection.Here's a quick patch that should fix both problems...
-
Rasmus Rønn Nielsen
I've run into this problem running ruby1.9.1 and rails 3 beta. I'm trying to use two "render :layout do [something] end" inside each other.
-
Aditya
- Importance changed from to
Confirm that this is a problem on 2.3.8 as well.
Leandro's patch fixes the problem of repeated output when passing collection is used problem.
Render layout with block however is not working (with or without the patch above).Ruby -v
ruby 1.8.7 (2010-06-07 patchlevel 268) -
Santiago Pastorino
- Tag changed from 2.3.5, content_for, layout, render, yield to content_for, layout, render, yield
- Assigned user set to Santiago Pastorino
- State changed from new to open
- Milestone cleared.
- Importance changed from to Medium
Leandro can you provide a patch following http://rails.lighthouseapp.com/projects/8994/sending-patches and add a test for this cases?.
Thank you. -
Neeraj Singh
I am not able to reproduce this problem in 2-3-stable. However Aditya was able to recreate this problem just 3 days ago. Not sure what's going on.
Can someone else try?
-
masone
I can reproduce the output described by Jeff with Rails 2.3.8, Ruby 1.8.7 and 1.9.2.
-
Santiago Pastorino
Is this an issue on master too? or only 2-3-stable?
-
Rohit Arondekar
- Milestone set to 2.3.9
I can't reproduce this on 3-0-stable. Changing milestone.
Can somebody please try this in 2-3-stable?
-
Santiago Pastorino
masone has reproduced this on 2.3.8 on July 18th, can you try it on 2-3-stable from git?.
And can someone provide a patch -
jgeiger
I've created a sample app that may or may not be this issue but is very similar. I'm not sure that the yields are causing the failures.
-
Shimon Young
Isn't this because actionpack-3.0.0\lib\action_view\render\rendering.rb is:
def render(options = {}, locals = {}, &block) case options when Hash if block_given? _render_partial(options.merge(:partial => options[:layout]), &block)where it should be?
def render(options = {}, locals = {}, &block) case options when Hash if block_given? options.merge!(:partial => options[:layout]) options.delete(:layout) _render_partial(options, &block) -
Santiago Pastorino
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
