No release in over 3 years
Low commit activity in last 3 years
Dead simple nested layouts for Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Rails Nestable Layouts

Gem Version CI Status 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