doc: number_format add math calculation hint

This commit is contained in:
Gordon Franke
2019-10-13 13:36:48 +02:00
committed by GitHub
parent 23419a9408
commit 954ab4b8e3
+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: