有没有办法从另一个调用Handlebars助手?我有一个名为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 ''}"
从主要的yourSavings
我想称之为:
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
但是在解决路径方面存在问题 - 我不能只将一个数字传递给currency
。有可能吗?