node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey »



Extension for tonic.js which renders Handlebars templates when jobs complete.


After creating a tonic application, register tonic-hbs using the use method on your tonic application.

var tonic = require('tonic'),
    hbs = require('tonic-hbs');
var app = tonic();


Templates and helper methods can be configured using your tonic application's config.json file.

  "handlebars": {
    "templates": [
      { "template": "templates/index.hbs", "filename": "public/index.html" },
      { "template": "templates/about.hbs", "filename": "public/about.html" }
    "helpers": "lib/helpers.js"

Each template must be defined individually. The filename attribute is where the output will be written.

An, optional, helpers JavaScript file can be provided.

All paths must be relative to the working directory of the tonic application.

Defining Helpers

The helpers JavaScript file must export a single function which takes a Handlebars object.

module.exports = function(Handlebars) {
  Handlebars.registerHelper('json', function(object) {
    return new Handlebars.SafeString(JSON.stringify(object) || '');
  Handlebars.registerHelper('pretty_json', function(object) {
    return new Handlebars.SafeString(JSON.stringify(object, null, 2) || '');