Works with [assemble][], [verb][], [generate][], [update][], or any [Template][]-based application. Just replace assemble in the examples with your application of choice.
This requires front-matter to be parsed in advance. You can easily do this with [parser-front-matter][] like this:
var assemble = require('assemble');
var app = assemble();
// parse front matter on all `hbs` files
app.onLoad(/\.hbs$/, function(view, next) {
matter.parse(view, next);
});
Use as a middleware:
var expand = require('{%= name %}');
var assemble = require('assemble');
var app = assemble();
app.onLoad(/\.hbs$/, expand(app));
app.pages('*.hbs');
app plugin
Use as an "instance" plugin on app
to expand templates in the front-matter of all views in all collections:
var expand = require('{%= name %}');
var assemble = require('assemble');
var app = assemble();
app.use(expand());
app.pages('*.hbs');
Collection plugin
Use as a collection instance plugin to expand templates in the front-matter of all views in the collection:
var expand = require('{%= name %}');
var assemble = require('assemble');
var app = assemble();
app.create('pages')
.use(expand(app));
app.pages('*.hbs');
view plugin
Use as a view plugin to expand templates in the front-matter of a specific view:
var expand = require('{%= name %}');
var assemble = require('assemble');
var app = assemble();
app.create('pages')
app.page('foo', {content: '...'})
.use(expand(app))
.render(function(err, res) {
//=> do stuff to res
});