mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-10 01:16:52 +00:00
doc: number_format add math calculation hint
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user