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

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:

<div class='column'>   <%=     render(       :partial => 'shared/edit/title',       :layout => 'shared/pane',       :locals => {         :pane => View::Pane.new( 'pane-dark', :filled => View::Pane::FILLED ),         :done_href => 'javascript:void(0);'       }     )   %> </div> <div class='columns'>   <div class='column-l'>     <%= yield %>   </div>   <div class='column-r'>     ...   </div> </div>

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.

I fixed it by first saving yield to a local

<% yield_output = yield %>


<% yield_output %>

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