Download

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;

What are you waiting for?

Start building your site today.

  1. 1 Download Publii
  2. 2 Write your content
  3. 3 Publish your site
Create website