decimal
Decimal formats a number with a fixed number of decimal places.
Decimal formats a number with a fixed number of decimal places. The default is 2.
Input
float int string
Parameters
| # | Type | Required |
|---|---|---|
| 0 | int | no |
Returns
string
Examples
Format a price with two decimals
Input
amount = 19.5Template
{{ amount | decimal:2 }}Output
19.50Round a weight to one decimal
Input
weight = 4.872Template
{{ weight | decimal:1 }}Output
4.9Use the default of two decimals
Input
total = 7Template
{{ total | decimal }}Output
7.00How is this guide?