Announcing Nestive – Better Nested Layouts for Rails

Justin French, May 2011

Last night at the monthly Melbourne Ruby meet-up I gave a quick presentation on Nested Layouts (aka Inheritable Layouts, Extensible Layouts, etc). I stepped through a bunch of the options, plugins and strategies available today, then finally showed off a new plugin I’ve been working on called Nestive.

Nestive is a partial answer to two things that have been really bugging me:

  1. The current Rails best practice for nested layouts, as described in the Rails Guides is utterly flawed for anything except the most basic examples
  2. I’ve had serious framework envy ever since Jeff Croft’s Django Templates: The Power of Inheritance was published back in 2006

We’re going to have trouble replicating Django’s DSL in ERB/ActionView (with keywords like `block` and `super`), but I think I’ve come up with a pretty tidy DSL involving just four simple methods.

You can read about all this in much more detail with a bunch of examples in the Nestive README on GitHub, or download the slides from my presentation (sorry there’s no presenter notes).

Right now, I’d love help from the community validating the entire concept. Try it out in a small project or a small part of a big project (it doesn’t mess with any of the Rails internals), try it with Haml, report issues, give me feedback on the DSL, etc.

I’m also wondering if it could be wired into Sinatra and other Ruby frameworks, and how it will impact things like Rails 3.1’s content streaming.

Fork it, patch it, break it, create issues, help me write some tests!