# \<%= yield %\> displays previous render's \<%= yield %\>

**URL:** <https://www.ruby-forum.com/t/yield-displays-previous-renders-yield/133699>\
**Category:** Rails\
**Created:** [April 2, 2008, 7:18pm UTC](https://www.ruby-forum.com/t/yield-displays-previous-renders-yield/133699 "2008-04-02T19:18:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![apramanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9a140/32.png) [@apramanik](https://www.ruby-forum.com/u/apramanik)\
**Post date:** [April 2, 2008, 7:18pm UTC](https://www.ruby-forum.com/t/yield-displays-previous-renders-yield/133699/1 "2008-04-02T19:18:17Z")

</div>

Hi all,

I’m trying to get a nested partial to display, but yield keeps  
displaying the previous render’s yield.

I have a view:

\<%=  
render(  
:partial =\> ‘user/edit\_photo’,  
:layout =\> ‘shared/edit’  
)  
%\>

The partial’s layout:

 \<%= render( :partial =\> 'shared/edit/title', :layout =\> 'shared/pane', :locals =\> { :pane =\> View::Pane.new( 'pane-dark', :filled =\> View::Pane::FILLED ), :done\_href =\> 'javascript:void(0);' } ) %\>

 \<%= yield %\> 

 ... 

When the page actually renders, the partial’s yield outputs ‘shared/  
edit/title’. When I remove the rendering of ‘shared/edit/title’, the  
yield correctly outputs ‘user/edit\_photo’. Why? If you are wondering  
why the view just renders a partial, it is because I have a layout  
that wraps the view and wanted another layout that would do some more  
wrapping.

---

<div class="post-metadata">

**Author:** ![apramanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9a140/32.png) [@apramanik](https://www.ruby-forum.com/u/apramanik)\
**Post date:** [April 2, 2008, 7:37pm UTC](https://www.ruby-forum.com/t/yield-displays-previous-renders-yield/133699/2 "2008-04-02T19:37:13Z")

</div>

I fixed it by first saving yield to a local

\<% yield\_output = yield %\>

…

\<% yield\_output %\>

Still wondering I couldn’t just do \<%= yield %\>
