Formatting money in twig templates

umpirsky picture umpirsky · May 7, 2011 · Viewed 64.1k times · Source

Are there any filters or something like that in twig template engine to format money or numbers?

Answer

Jrgns picture Jrgns · Feb 1, 2012

The number_format filter has been included in the Twig core since the end of December 2011. The relevant commit is here.

Usage: number_format(decimals, decimalSeparator, thousandSeparator)

{{ total|number_format(2) }}
{{ total|number_format(0, '.') }}
{{ total|number_format(2, '.', ',') }}

Read more about it in the docs