barc/express-hbs — pull request #38 by olance (2013-11-22 21:29:46+00:00)
Title: Add support for nested layouts

New pull request merged with the very last changes in barc/express-hbs:master :)

Added the capability to nest layouts by tweaking the code a bit:

* The "entry point" for layout inclusion doesn't change: it's either declared in the template given to `compileFile`, given as an option to `render` or as a global `defaultTemplate` option
* However, `cacheLayout` will now check whether the loaded layout template declares a layout (using `{{!< LAYOUT}}` as in templates). If it does, this "parent" layout will be loaded and again, checked for any declared parent layout. The layout hierarchy is loaded up to the top recursively, until no layout declaration is found. This recursion will result in a layout stack listing all layouts templates, from the outermost to the innermost, required to render the page template.
* For each loaded layout, the parents layout stack is cached, just like it was when the code managed a single layout
* Consequently, `render` has been adapted to work with a template and its layouts stack, rendering each layout in the stack with the "concatenated" rendering of previous template/layouts.