Search code examples
javascripthandlebars.js

tryhandlebarsjs Register Helper functions


I am playing around with tryhandlebarsjs.com

I have following function:

export const cellHelper = {
    name: "cell",
    handler: (context) => {
        //...
        return template
    }
}

If I pass it as is I get Error(s): SyntaxError: Unexpected token export. What is the correct syntax to pass it into tryhandlebarsjs.com?


Solution

  • Pass it like this:

    Handlebars.registerHelper('cell', function(context) {
       //...
       return template
    });