Nested Layouts plugin
Plugin details
Documentation
ruby script/plugin install svn://rubyforge.org/var/svn/nested-layouts/trunk/nested_layouts
Concept of layout nesting here is based on the assumption that every inner layout is used only to customize it’s outer layout and thus every inner layout is used only with one specific outer layout. With this in mind we can conclude that every layout must know it’s outer layout and thus information about outer layout must be embeded directly into inner layout. Controller doesn’t need to know about the whole stack of layouts, so you should just specify the most inner layout in it.
Let’s assume you have controller which action ‘hello’ just was called. Controller was set up to use ‘inner’ layout:
app/controllers/hello_controller.rb
class HelloController < ApplicationController layout 'inner' def hello render :text => 'Hello, world!' end end
app/views/layouts/inner.rhtml
<% inside_layout 'outer' do -%> < div class="hello"> Greetings <%= yield %> < /div> <% end -%>
app/views/layouts/outer.rhtml
< html> < body> < div class="content"> <%= yield %> < /div> < /body> < /html>
Result will look like this (formatted for better reading):
< html> < body> < div class="content"> < div class="hello"> < h1>Greetings< /h1> Hello, world! < /div> < /div> < /body> < /html>
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | Back in time (2 older versions) | Last edited by: maxim_kulkin, 9 months ago

