# Layout view helper

**URL:** <https://www.ruby-forum.com/t/layout-view-helper/125203>\
**Category:** Rails\
**Created:** [January 7, 2008, 1:41am UTC](https://www.ruby-forum.com/t/layout-view-helper/125203 "2008-01-07T01:41:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [January 7, 2008, 1:41am UTC](https://www.ruby-forum.com/t/layout-view-helper/125203/1 "2008-01-07T01:41:13Z")

</div>

Hi,

I’m hoping to get some tips on how I could do this. I want a helper,  
called “layout”, which will take the contents of the current action  
(not including the layout set by controller) and put it inside of  
another layout. As simple as:

example.html,erb  
\<% layout ‘sub\_layout\_1’ %\>  
Everything here would get put inside of the sub\_layout\_1 layout,  
including any partials I use…

I used to do this in PHP with either a call back handler to the layout  
helper, or in a register\_shutdown\_function, both using output  
buffering.

Does anyone know how I could do this? I actually have NO idea, but am  
hoping to find something.

Matt

---

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [January 7, 2008, 10:28am UTC](https://www.ruby-forum.com/t/layout-view-helper/125203/2 "2008-01-07T10:28:44Z")

</div>

On 7 Jan 2008, at 00:40, goodieboy wrote:

> Everything here would get put inside of the sub\_layout\_1 layout,  
> including any partials I use…

Are you looking for content\_for ?

Fred
