有没有办法从另一个人那里调用 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
. 可能吗?