javascript - How to store a template in an expression in Handlebars.js? -


i want place templates on several places in dom without having write jquery expression on , on again. want place template in dom typing variable/attribute {{template}} anywhere in body.

is doable using handlebars? if not, there other way me achieve this?

you need use handlebar helpers

handlebar_helpers
p.s. dont forget use safestring else escaped default



updating answer based on ur comment link provided did give out excellent explanation. please find below example.
assume need return welcome message when name given

handlebars.registerhelper('welcome', function(name) {   return new handlebars.safestring(     "<p>hi "+name+", welcome stackoverflow</p>"   ); }); 

then calling {{{welcome "sagittarius"}}} return

hi sagittarius, welcome stackoverflow


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -