Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including customize-engine-handlebars with all npm packages installed. Try it out:

require("customize/package.json"); // customize is a peer dependency. var customizeEngineHandlebars = require("customize-engine-handlebars")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

customize-engine-handlebars v3.0.1

Use handlebars as engine for customize


NPM version Travis Build Status Coverage Status Greenkeeper badge

Use handlebars as engine for customize


npm install customize-engine-handlebars


The following examples demonstrate how to use this module.


The following usage example has a configuration for all possible properties of the Handlebars-engine:

var customize = require('customize')
  .registerEngine('handlebars', require('customize-engine-handlebars'))

This example loads its configuration from the module config-module.js:

module.exports = function (customize) {
  return customize.merge({
    handlebars: {
      // Directory containing templates
      templates: 'templates',
      // Directory containing partials
      partials: 'partials',
      // JS-file exporting Handlebars helper-functions
      helpers: 'hb-helpers.js',
      // JS-file exporting a preprocessor function
      preprocessor: 'hb-preprocessor.js',
      // Input data for Handlebars
      data: {
        name: 'nknapp',
        city: 'Darmstadt'

A quick note: If your are creating a real configuration-module, you should always use require.resolve or __dirname to determine the correct path to referenced files.

All the templates in the templates directory are called with the provided data (name and city). Each one generates an entry in the result of the engine. The templates call a partial that is inserted below the main content. Helper functions from the hb-helpers.js-file are registered with Handlebars and text2.txt.hbs uses the shout-helper from hb-helpers.js to turn a string into upper-case.

I'm {{name}}

I'm living in {{shout city}}.


The example also includes a preprocessor (hb-preprocessor.js) that calls the github API to retrieve information about the user.

const got = require('got').extend({
  json: true

module.exports = function (data) {
  return {
    github: got('').then(response => response.body)

The result is injected into the data as github property and rendered by the footer.hbs partial.

Github-Name: {{{}}}

The output of this example is:

  "handlebars": {
    "subdir/text3.txt": "------\nGithub-Name: Nils Knappmeier",
    "text1.txt": "I'm nknapp\n\nI'm living in Darmstadt.\n\n------\nGithub-Name: Nils Knappmeier",
    "text2.txt": "I'm nknapp\n\nI'm living in DARMSTADT.\n\n------\nGithub-Name: Nils Knappmeier"

More examples

see docs/ for more examples


This package will always support the latest version of NodeJS and as well as the current LTS version. In the future, it will not be considered a breaking change to drop support of a pre-LTS version of NodeJS.

see docs/


customize-engine-handlebars is published under the MIT-license.

See for details.


For release notes, see

Contributing guidelines


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free