I\'m totally new to js template engines. Handlebars seems to be the popular choice. I don\'t dislike the syntax for doing conditions, loops and so on, but since I\'m perfect
Sorry to resurrect a old issue here. If you have to use handlebars or it's not feasible to change your templating library you can use Helpers from the Handlebars library.
http://handlebarsjs.com/expressions.html#helpers
Registering a helper in handlebar can be a walk around to what you are trying to do. See this link for a complete example: Registering handlebars helpers with node does absolutely nothing
One of the central ideas behind handlebars and mustache is they are LOGICLESS by design and intention. They can not now, nor will they ever allow or recommend you embed raw JS in your templates. Some say this is a better design. If you want embedded javascript, almost every other traditional templating engine, such as _.template or jade or EJS is based on (or at least supports) the idea of embedded JS code snippets.