Rails Nestable Layouts - Dead simple nested layouts for Rails
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
CHANGELOG.md
Gemfile
LICENSE
README.md
Rakefile
rails_nestable_layouts.gemspec

README.md

Rails Nestable Layouts

Gem Version RubyGems Downloads Buy Me a Coffee

Dead simple nested layouts support for Rails. Does not monkey patch anything. Can nest as many layouts as desired.

Install

gem 'rails_nestable_layouts'

Usage

Your Controller

# main layout, this line is not necessary. Note nested_layouts does not override the main layout.
layout :application 

# accepts the same options as before_action/before_filter
nested_layouts 'layouts/secondary_layout', 'posts/layout', except: [:index] 

Main Layout

<html>
  <head></head>
  <body>
    <h1>My Main Layout</h1>
    
    <!-- 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)

<h2>My Nested Layout</h2>

<%= yield_nested %> # this will call the next nested layout or the requested template if no more nested layouts.

Credits

Created by Weston Ganger - @westonganger

Buy Me a Coffee