How to create a custom helper?

Custom helpers can be created in the helpers.js file. It is useful if you need to create more complex conditions and you want to simplify your theme structure.

It is necessary to create an object with functions which will define an output of the helper. The key values in the object are used as a helper names.

In the below example there is a {{testHelper}} defined, which accepts a one argument:


/*
 * Custom theme helpers for Handlebars.js
 */

let themeHelpers = {
    testHelper: function(value) {
        return "Test output " + value;
    }
};

module.exports = themeHelpers;