From 954ab4b8e39b3226415752a372af60106bf09426 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Sun, 13 Oct 2019 13:36:48 +0200 Subject: [PATCH] doc: number_format add math calculation hint --- doc/filters/number_format.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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: