calling Handlebars helper from another one
Is there a way of calling a Handlebars helper from another one? I have a
helper called currency:
Ember.Handlebars.helper 'currency', (amount, options) ->
rounded = Math.round amount * 100
dec = rounded % 100
whole = rounded / 100 - dec / 100
decStr = dec.toString()
"$#{whole}.#{decStr}#{if decStr.length < 2 then '0' else ''}"
and from the main one, yourSavings I wanted to call it:
Ember.Handlebars.helper 'yourSavings', (amount, amount2, options) ->
result = amount2 - amount
result = if not result or result < 0 then 0 else result
args = Array.prototype.slice.call arguments, 2
args.unshift result
Ember.Handlebars.helpers.currency.apply @, args
but had problems with resolving paths - I couldn't just pass in a number
to the currency. Is it possible?
No comments:
Post a Comment