currency
Converts a numeric value between currency units by scaling it with a ratio of unit sizes: the result is value * toUnits / fromUnits, truncated to a whole integer.
A string value may carry a leading currency symbol ($, EUR, GBP, JPY), which is stripped before parsing. A value that is neither a number nor a string counts as zero.
InputArgumentsReturns
SourceanyintintintBasicSource
Converts a numeric value between currency units by scaling it with a ratio of unit sizes, here dollars into cents.
Given
{"price": 9}Template
{{ price | currency:1,100 }}Result
900SymbolSource
Strips a leading currency symbol from a string value before scaling it.
Given
{"price": "$4.50"}Template
{{ price | currency:1,100 }}Result
450To dollarsSource
Scales cents back down to whole dollars by giving the larger unit size first.
Given
{"price": 900}Template
{{ price | currency:100,1 }}Result
9TruncatesSource
Drops the fractional part of the result rather than rounding it.
Given
{"price": 1.99}Template
{{ price | currency:1,1 }}Result
1