diff --git a/doc/filters/number_format.rst b/doc/filters/number_format.rst index 564de30e6..eca99eab4 100644 --- a/doc/filters/number_format.rst +++ b/doc/filters/number_format.rst @@ -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 `: .. 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: