Update number_format.rst

This commit is contained in:
DarkBee
2017-05-15 09:10:53 +02:00
committed by Fabien Potencier
parent c6bd2df147
commit 40fdb9e3e5
+10
View File
@@ -17,6 +17,14 @@ separator using the additional arguments:
.. code-block:: jinja
{{ 9800.333|number_format(2, '.', ',') }}
If you want to format negative numbers, you will need to wrap the number with parantheses. This is due to the `precedence of operators`_ inside Twig
.. code-block:: jinja
{{ -9800.333|number_format(2, '.', ',') }} {# outputs : -9 #}
{{ (-9800.333)|number_format(2, '.', ',') }} {# outputs : -9.800,33 #}
If no formatting options are provided then Twig will use the default formatting
options of:
@@ -46,3 +54,5 @@ Arguments
* ``thousand_sep``: The character(s) to use for the thousands separator
.. _`number_format`: http://php.net/number_format
.. _`precedence of operators`: https://twig.sensiolabs.org/doc/2.x/templates.html#expressions