visionmedia/ejs — pull request #147 by mostly-magic (2013-11-26 19:15:53+00:00)
Title: Adds support of layout and blocks to EJS

I've added supoort for layouts to EJS. The key features are:

- Imports layout files specified with <% layout ... %>
- Parses blocks identified with <% block ... %>
- Exposes blocks to layout files with local `block` variables
- Supports multi-layered layouts; child blocks override parent blocks

I saw that @ictliujie also has a pull request for this feature (#142), but since I was also working on my own implementation I thought it should submit it for discussion. The key differences are:

- **Minimal syntax changes:** The only addition are the layout and block commands. No need to add <%+ and <%/ directives
- **Implicit end block:** Blocks are implicitly ended when the next block is defined, or EOF is reached. This removes the need for the <%/block%> statement
- **Local `blocks` variable:** Layouts can access blocks using a local `blocks` variable. This provides the greatest flexiblity for implementation.