Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Handlebars.registerHelper smartdocs template

Is it possible to register HandleBars helpers in a smartdocs template?

I am trying to do something like this

Handlebars.registerHelper('equal', function(lvalue, rvalue, options) {
    if (arguments.length < 3)
        throw new Error("Handlebars Helper equal needs 2 parameters");
    if( lvalue!=rvalue ) {
        return options.inverse(this);
    } else {
        return options.fn(this);
    }
});
Solved Solved
0 2 369
1 ACCEPTED SOLUTION

Marsh
Former Googler

As far as I know, you cannot register Handlebars helpers in SmartDocs templates. You may be able to include some JavaScript to be executed by the client if you're looking to apply logic to inputs.

View solution in original post

2 REPLIES 2

Marsh
Former Googler

As far as I know, you cannot register Handlebars helpers in SmartDocs templates. You may be able to include some JavaScript to be executed by the client if you're looking to apply logic to inputs.

To clarify: while it is not possible to register a helper from within the template itself, it is absolutely possible for people to register Handlebars helpers from within a additional Javascript module that augments the builtin smartdocs JS.