4.1.0 • Published 9 years ago

webant-handler-hbs v4.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

node-modules-webant-handler-hbs

Require handlebars templates with webant

Installation

$ npm install webant-handler-hbs

Usage

Ensure the hbs handler is present in your webant configuration file. For example:

{
    "entry":"src/js/main.js",
    "dest":"build/main.js",
    "handlers":["hbs"]
}

You may now require handlebars files:

var tmpl = require("./path/to/template.hbs");
var otherTmpl = require("./path/to/template.handlebars");
var html = tmpl({name:"Jane Doe"});

Settings

The following configuration settings are available:

requireRuntime

Can be either true (default) or false. If true, the handlebars runtime is automatically required along with the template. This allows easier usage of the template as follows:

var tmpl = require("./path/to/template.hbs");
var html = tmpl({name:"Jane Doe"});

If set to false, you'll need to include the handlebars runtime yourself as follows:

var hbs = require("path/to/handlebars.runtime.js");
var tmpl = require("./path/to/template.hbs");
var tmplFunc = hbs['default'].template(tmpl);
var html = tmplFunc({name:"Jane Doe"});

It may be necessary to modify the handlebars runtime to export the Handlebars object by appending the following line:

// Handlebars code...
module.exports = Handlebars;

Tests Build Status

Ensure phantomjs is installed and in your PATH, then run:

$ npm test
4.1.0

9 years ago

4.0.1

9 years ago

3.0.1

10 years ago

3.0.0

10 years ago

2.0.0

10 years ago

1.1.1

10 years ago

1.0.0

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.1

11 years ago