@@ -22,37 +22,37 @@ The list of supported options:
22
22
* ``grouping_used ``: Specifies whether to use grouping separator for thousands::
23
23
24
24
{# 1,234,567.89 #}
25
- {{ 1234567.89|format_number({grouping_used:true}, locale= 'en') }}
25
+ {{ 1234567.89|format_number({grouping_used:true}, locale: 'en') }}
26
26
27
27
* ``decimal_always_shown ``: Specifies whether to always show the decimal part, even if it's zero::
28
28
29
29
{# 123. #}
30
- {{ 123|format_number({decimal_always_shown:true}, locale= 'en') }}
30
+ {{ 123|format_number({decimal_always_shown:true}, locale: 'en') }}
31
31
32
32
* ``max_integer_digit ``:
33
33
* ``min_integer_digit ``:
34
34
* ``integer_digit ``: Define constraints on the integer part::
35
35
36
36
{# 345.679 #}
37
- {{ 12345.6789|format_number({max_integer_digit:3, min_integer_digit:2}, locale= 'en') }}
37
+ {{ 12345.6789|format_number({max_integer_digit:3, min_integer_digit:2}, locale: 'en') }}
38
38
39
39
* ``max_fraction_digit ``:
40
40
* ``min_fraction_digit ``:
41
41
* ``fraction_digit ``: Define constraints on the fraction part::
42
42
43
43
{# 123.46 #}
44
- {{ 123.456789|format_number({max_fraction_digit:2, min_fraction_digit:1}, locale= 'en') }}
44
+ {{ 123.456789|format_number({max_fraction_digit:2, min_fraction_digit:1}, locale: 'en') }}
45
45
46
46
* ``multiplier ``: Multiplies the value before formatting::
47
47
48
48
{# 123,000 #}
49
- {{ 123|format_number({multiplier:1000}, locale= 'en') }}
49
+ {{ 123|format_number({multiplier:1000}, locale: 'en') }}
50
50
51
51
* ``grouping_size ``:
52
52
* ``secondary_grouping_size ``: Set the size of the primary and secondary grouping separators::
53
53
54
54
{# 1,23,45,678 #}
55
- {{ 12345678|format_number({grouping_size:3, secondary_grouping_size:2}, locale= 'en') }}
55
+ {{ 12345678|format_number({grouping_size:3, secondary_grouping_size:2}, locale: 'en') }}
56
56
57
57
* ``rounding_mode ``:
58
58
* ``rounding_increment ``: Control rounding behavior, here is a list of all rounding_mode available:
@@ -67,7 +67,7 @@ The list of supported options:
67
67
.. code-block :: twig
68
68
69
69
{# 123.5 #}
70
- {{ 123.456|format_number({rounding_mode:'ceiling', rounding_increment:0.05}, locale= 'en') }}
70
+ {{ 123.456|format_number({rounding_mode:'ceiling', rounding_increment:0.05}, locale: 'en') }}
71
71
72
72
* ``format_width ``:
73
73
* ``padding_position ``: Set width and padding for the formatted number, here is a list of all padding_position available:
@@ -79,19 +79,19 @@ The list of supported options:
79
79
.. code-block :: twig
80
80
81
81
{# 123 #}
82
- {{ 123|format_number({format_width:10, padding_position:'before_suffix'}, locale= 'en') }}
82
+ {{ 123|format_number({format_width:10, padding_position:'before_suffix'}, locale: 'en') }}
83
83
84
84
* ``significant_digits_used ``:
85
85
* ``min_significant_digits_used ``:
86
86
* ``max_significant_digits_used ``: Control significant digits in formatting::
87
87
88
88
{# 123.4568 #}
89
- {{ 123.456789|format_number({significant_digits_used:true, min_significant_digits_used:4, max_significant_digits_used:7}, locale= 'en') }}
89
+ {{ 123.456789|format_number({significant_digits_used:true, min_significant_digits_used:4, max_significant_digits_used:7}, locale: 'en') }}
90
90
91
91
* ``lenient_parse ``: If true, allows lenient parsing of the input::
92
92
93
93
{# 123 #}
94
- {{ 123|format_number({lenient_parse:true}, locale= 'en') }}
94
+ {{ 123|format_number({lenient_parse:true}, locale: 'en') }}
95
95
96
96
Besides plain numbers, the filter can also format numbers in various styles::
97
97
@@ -109,37 +109,37 @@ The list of supported styles:
109
109
* ``decimal ``::
110
110
111
111
{# 1,234.568 #}
112
- {{ 1234.56789 | format_number(style= 'decimal', locale= 'en') }}
112
+ {{ 1234.56789 | format_number(style: 'decimal', locale: 'en') }}
113
113
114
114
* ``currency ``::
115
115
116
116
{# $1,234.56 #}
117
- {{ 1234.56 | format_number(style= 'currency', locale= 'en') }}
117
+ {{ 1234.56 | format_number(style: 'currency', locale: 'en') }}
118
118
119
119
* ``percent ``::
120
120
121
121
{# 12% #}
122
- {{ 0.1234 | format_number(style= 'percent', locale= 'en') }}
122
+ {{ 0.1234 | format_number(style: 'percent', locale: 'en') }}
123
123
124
124
* ``scientific ``::
125
125
126
126
{# 1.23456789e+3 #}
127
- {{ 1234.56789 | format_number(style= 'scientific', locale= 'en') }}
127
+ {{ 1234.56789 | format_number(style: 'scientific', locale: 'en') }}
128
128
129
129
* ``spellout ``::
130
130
131
131
{# one thousand two hundred thirty-four point five six seven eight nine #}
132
- {{ 1234.56789 | format_number(style= 'spellout', locale= 'en') }}
132
+ {{ 1234.56789 | format_number(style: 'spellout', locale: 'en') }}
133
133
134
134
* ``ordinal ``::
135
135
136
136
{# 1st #}
137
- {{ 1 | format_number(style= 'ordinal', locale= 'en') }}
137
+ {{ 1 | format_number(style: 'ordinal', locale: 'en') }}
138
138
139
139
* ``duration ``::
140
140
141
141
{# 2:30:00 #}
142
- {{ 9000 | format_number(style= 'duration', locale= 'en') }}
142
+ {{ 9000 | format_number(style: 'duration', locale: 'en') }}
143
143
144
144
As a shortcut, you can use the ``format_*_number `` filters by replacing ``* ``
145
145
with a style::
0 commit comments