Rails Nestable Layouts
Dead simple nested layouts support for Rails. Does not monkey patch anything. Can nest as many layouts as desired.
Install
# Gemfile
gem 'rails_nestable_layouts'
Usage
# Controller
layout :application # main layout, this line is not necessary. Note nested_layouts does not override the main layout.
nested_layouts 'layouts/secondary_layout', 'posts/layout', except: [:index] # accepts the same options as before_action/before_filter
# Main Layout
<html>
<head></head>
<body>
# this will call the first nested layout , will fallback to normal functionality if no nested layouts.
<%= yield_nested %> #
</body>
<footer></footer>
</html>
# Nested Layout(s)
<h1>Foo Bar</h1>
<div id="myContainer">
<%= yield_nested %> # this will call the next nested layout or the requested template if no more nested layouts.
</layout>
Credits
Created by Weston Ganger - @westonganger