decimal
Formats a number with the given number of decimal places, rounding to the nearest value at that precision.
InputArgumentsReturns
Sourceanyintstringanyno argumentsstringBasicSource
Formats a number with the given number of decimal places, rounding to the nearest value at that precision.
Given
{"ratio": 1.23456}Template
{{ ratio | decimal:4 }}Result
1.2346ZeroSource
Rounds to a whole number when zero decimal places are requested.
Given
{"n": 42.7}Template
{{ n | decimal:0 }}Result
43BasicSource
Formats a number with two decimal places, the clause reached when no precision is given.
Given
{"price": 3.5}Template
{{ price | decimal }}Result
3.50StringSource
Parses a numeric string before formatting it, so a value that arrives as text still renders with two decimal places.
Given
{"amount": "7.5"}Template
{{ amount | decimal }}Result
7.50