minor #3170 doc: number_format add math calculation hint (gimler)

This PR was merged into the 2.x branch.

Discussion
----------

doc: number_format add math calculation hint

Add hint about number_format and math calculation

Commits
-------

954ab4b8 doc: number_format add math calculation hint
This commit is contained in:
Fabien Potencier
2019-10-17 09:25:09 +02:00
+3 -1
View File
@@ -15,13 +15,15 @@ separator using the additional arguments:
{{ 9800.333|number_format(2, '.', ',') }}
To format negative numbers, wrap the number with parentheses (needed because of
To format negative numbers or math calculation, wrap the previous statement with parentheses (needed because of
Twig's :ref:`precedence of operators <twig-expressions>`:
.. code-block:: twig
{{ -9800.333|number_format(2, '.', ',') }} {# outputs : -9 #}
{{ (-9800.333)|number_format(2, '.', ',') }} {# outputs : -9,800.33 #}
{{ 1 + 0.2 | number_format(2) }} {# outputs : 1.2 #}
{{ (1 + 0.2) | number_format(2) }} {# outputs : 1.20 #}
If no formatting options are provided then Twig will use the default formatting
options of: