Rounding

Integers can be rounded with the round filter

{{ number|round }}

Make sure to cast floats and strings to integers to properly round them!

{{ number|round|int }}

Basic Currency

Python’s string formatting can be used to format currency:

{{ "$%.2f"|format(price) }}

International Currency

Using swu.lib you have access to Babel’s number functions

{{swu.lib.babel.numbers.format_currency(value,'USD',locale="nl_NL")}}

Troubleshooting

Still getting errors? Your value may be coming in as a string, try converting it to a float:

{{ "$%.2f"|format(value|float) }}

Additional Resources