aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/twig/twig/doc/filters/number_format.rst
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twig/twig/doc/filters/number_format.rst')
-rw-r--r--vendor/twig/twig/doc/filters/number_format.rst45
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/twig/twig/doc/filters/number_format.rst b/vendor/twig/twig/doc/filters/number_format.rst
new file mode 100644
index 00000000..fedacd9d
--- /dev/null
+++ b/vendor/twig/twig/doc/filters/number_format.rst
@@ -0,0 +1,45 @@
1``number_format``
2=================
3
4.. versionadded:: 1.5
5 The number_format filter was added in Twig 1.5
6
7The ``number_format`` filter formats numbers. It is a wrapper around PHP's
8`number_format`_ function:
9
10.. code-block:: jinja
11
12 {{ 200.35|number_format }}
13
14You can control the number of decimal places, decimal point, and thousands
15separator using the additional arguments:
16
17.. code-block:: jinja
18
19 {{ 9800.333|number_format(2, '.', ',') }}
20
21If no formatting options are provided then Twig will use the default formatting
22options of:
23
24- 0 decimal places.
25- ``.`` as the decimal point.
26- ``,`` as the thousands separator.
27
28These defaults can be easily changed through the core extension:
29
30.. code-block:: php
31
32 $twig = new Twig_Environment($loader);
33 $twig->getExtension('core')->setNumberFormat(3, '.', ',');
34
35The defaults set for ``number_format`` can be over-ridden upon each call using the
36additional parameters.
37
38Arguments
39---------
40
41 * ``decimal``: The number of decimal points to display
42 * ``decimal_point``: The character(s) to use for the decimal point
43 * ``decimal_sep``: The character(s) to use for the thousands separator
44
45.. _`number_format`: http://php.net/number_format