segmentio/metalsmith-templates — pull request #27 by mayo (2014-10-02 17:42:51+00:00)
Title: Support template inheritance from content files

I don't expect this to be accepted, but would like it to instigate a discussion on supporting something similar to this. I think more automation (ie. not having users specify block patterns manually) and testing with different templating libraries (tested only with jade and swig) would be required before this is ready for public consumption. Perhaps consolidate.js -like wrapper for templating libraries that support blocks would help as well.

The base of the idea is that for template languages that support blocks (atpl, dust, ect, Hogan, just, nunjucks, swig and potentially liquor), there is no way to override template blocks from content files without creating dummy content-file specific templates (template file per content file).

The changes cause content files to extend a template (given the proper setup in front-matter) and thus allow overriding of blocks specified in the template. Optionally, the content can also be wrapped in a block itself, giving a bit more flexibility to templating.

Because there is no universal way of specifying blocks, the current implementation expects the user to specify block definition of their templating language of choice (`extendsPattern`, `blockPattern`).

If none of the new options are used when setting up the plugin in metalsmith, the plugin works as normal without any side effects. New functionality will be triggered only when `useExtends` is specified in plugin setup and a content file has an `extends` keyword in front-matter.

Any flames, blames, ideas or comments are welcome.