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
Post a Comment