Name: helper-front-matter
Owner: Helpers
Description: Template helper for parsing front matter and passing the data to templates as context.
Created: 2015-04-10 03:27:07.0
Updated: 2015-04-10 11:28:36.0
Pushed: 2015-04-10 03:29:30.0
Homepage: null
Size: 136
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Template helper for parsing front matter and passing the data to templates as context/
i helper-front-matter --save
First, let's register another cutomer helper for this example:
fs = require('fs');
handlebars = require('handlebars');
matter = require('helper-front-matter')(handlebars);
his is our helper
lebars.registerHelper('matter', matter(handlebars));
hese are extra helpers we'll use for examples
lebars.registerHelper('markdown', require('helper-markdown'));
lebars.registerHelper('read', function (fp) {
turn fs.readFileSync(fp, 'utf8');
Given you have a file, abc.hbs
, with the following contents:
e: ABC
bar
his is {{title}}
is is a blockquote
Used with the markdown
helper as a block helper:
arkdown}}
ading
atter (read "fixtures/abc.hbs")}}}
arkdown}}
Renders to:
Heading</h1>
This is ABC</h2>
ckquote>
his is a blockquote</p>
ockquote>
Used with the markdown
helper as an inline helper:
arkdown (matter (read "fixtures/abc.hbs"))}}}
Renders to:
This is ABC</h2>
ckquote>
his is a blockquote</p>
ockquote>
Install dev dependencies:
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.