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

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -