module ApplicationHelper def inside_layout(layout, &block) @template.instance_variable_set("@content_for_layout", capture(&block)) layout = layout.include?("/") ? layout : "layouts/#{layout}" if layout buffer = eval("_erbout", block.binding) buffer.concat(@template.render_file(layout, true)) end end
Then, design your views to use e.g. 'inner_layout'.
In 'layouts/inner_layout.rhtml' write:
<% inside_layout 'outer_layout' do %> layout stuff <%= @content_for_layout %> <% end %>
The 'outer_layout.rhtml' will go as ussual layout (unless it needs to be nested in other higher level layout)
This should really be in Rails core. :-)