node.js - Nested Operations in Handlebars -


i want use nested operation in handlerbars

if(value == "a" || value == "b") 

how can create equations using handlebar.

thanks in advance

create helper (i use underscore.js simplicify):

eq.js

handlebars.registerhelper('eq', function() {   var i, options, val1, vals;   val1 = arguments[0], vals = 3 <= arguments.length ? slice.call(arguments, 1, = arguments.length - 1) : (i = 1, []), options = arguments[i++];   return _.any(vals, function(val) {     return val1 === val;   }); }); 

or eq.coffee

handlebars.registerhelper 'eq', (val1, vals..., options) -> _.any vals, (val) -> val1 val 

and use:

{{eq value 'a' 'b'}} 

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -