helpers/helper-front-matter

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

helper-front-matter NPM version

Template helper for parsing front matter and passing the data to templates as context/

Install with npm
i helper-front-matter --save
Usage
Register the helper

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');

Create some templates

Given you have a file, abc.hbs, with the following contents:


e: ABC
 bar


his is {{title}}

is is a blockquote
Use the helpers

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>
Running tests

Install dev dependencies:

i -d && npm test
Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on April 09, 2015.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.