Template helper for parsing front matter and passing the data to templates as context/
Install with npm
npm i helper-front-matter --save
First, let's register another cutomer helper for this example:
var fs = require('fs');
var handlebars = require('handlebars');
var matter = require('helper-front-matter')(handlebars);
// this is our helper
handlebars.registerHelper('matter', matter(handlebars));
// these are extra helpers we'll use for examples
handlebars.registerHelper('markdown', require('helper-markdown'));
handlebars.registerHelper('read', function (fp) {
return fs.readFileSync(fp, 'utf8');
});
Given you have a file, abc.hbs
, with the following contents:
Used with the markdown
helper as a block helper:
Renders to:
<h1>Heading</h1>
<h2>This is ABC</h2>
<blockquote>
<p>this is a blockquote</p>
</blockquote>
Used with the markdown
helper as an inline helper:
Renders to:
<h2>This is ABC</h2>
<blockquote>
<p>this is a blockquote</p>
</blockquote>
Install dev dependencies:
npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb-cli on April 09, 2015.