javascript - Using Handlebars custom helper method to hide HTML -
i have following custom handlebars helper:
handlebars.registerhelper('isnewuser', function (userid) { return (userid < 1); });
and following html in view:
{{#isnewuser id}} <div> <input name="isactive" id="user-active" type="checkbox" checked /> active </div> {{/isnewuser}}
i can see function being hit, userid
parameter passed correctly, , return true
of type bool instead of showing block shows text 'true'.
how can html block hide handlebars without error'ing out?
i able fix after gaining insight stackoverflow question. changed helper method following:
handlebars.registerhelper('isnewuser', function (userid, options) { if (userid < 1) return options.fn(this); else return options.inverse(this); });
Comments
Post a Comment