@@ -55,6 +55,16 @@ TwigBundle Configuration ("twig")
55
55
paths :
56
56
' %kernel.root_dir%/../vendor/acme/foo-bar/templates ' : foo_bar
57
57
58
+ # The following were added in Symfony 2.7.
59
+ date :
60
+ format : d.m.Y, H:i:s
61
+ interval_format : ' %%d days'
62
+ timezone : Asia/Tokyo
63
+ number_format :
64
+ decimals : 2
65
+ decimal_point : ' ,'
66
+ thousands_separator : ' .'
67
+
58
68
.. code-block :: xml
59
69
60
70
<!-- app/config/config.xml -->
@@ -81,6 +91,9 @@ TwigBundle Configuration ("twig")
81
91
82
92
<twig : global key =" foo" id =" bar" type =" service" />
83
93
<twig : global key =" pi" >3.14</twig : global >
94
+
95
+ <twig : date format =" d.m.Y, H:i:s" interval-format =" %d days" timezone =" Asia/Tokyo" />
96
+ <twig : number-format decimals =" 2" decimal-point =" ," thousands-separator =" ." />
84
97
85
98
<twig : exception-controller >AcmeFooBundle:Exception:showException</twig : exception-controller >
86
99
<twig : path namespace =" foo_bar" >%kernel.root_dir%/../vendor/acme/foo-bar/templates</twig : path >
@@ -94,23 +107,33 @@ TwigBundle Configuration ("twig")
94
107
'form_themes' => array(
95
108
'form_div_layout.html.twig', // Default
96
109
'form.html.twig',
97
- ),
98
- 'globals' => array(
99
- 'foo' => '@bar',
100
- 'pi' => 3.14,
101
- ),
102
- 'auto_reload' => '%kernel.debug%',
103
- 'autoescape' => 'name',
104
- 'base_template_class' => 'Twig_Template',
105
- 'cache' => '%kernel.cache_dir%/twig',
106
- 'charset' => '%kernel.charset%',
107
- 'debug' => '%kernel.debug%',
108
- 'strict_variables' => false,
109
- 'exception_controller' => 'AcmeFooBundle:Exception:showException',
110
- 'optimizations' => true,
111
- 'paths' => array(
112
- '%kernel.root_dir%/../vendor/acme/foo-bar/templates' => 'foo_bar',
113
- ),
110
+ ),
111
+ 'globals' => array(
112
+ 'foo' => '@bar',
113
+ 'pi' => 3.14,
114
+ ),
115
+ 'auto_reload' => '%kernel.debug%',
116
+ 'autoescape' => 'name',
117
+ 'base_template_class' => 'Twig_Template',
118
+ 'cache' => '%kernel.cache_dir%/twig',
119
+ 'charset' => '%kernel.charset%',
120
+ 'debug' => '%kernel.debug%',
121
+ 'strict_variables' => false,
122
+ 'exception_controller' => 'AcmeFooBundle:Exception:showException',
123
+ 'optimizations' => true,
124
+ 'paths' => array(
125
+ '%kernel.root_dir%/../vendor/acme/foo-bar/templates' => 'foo_bar',
126
+ ),
127
+ 'date' => array(
128
+ 'format' => 'd.m.Y, H:i:s',
129
+ 'interval_format' => '%%d days',
130
+ 'timezone' => 'Asia/Tokyo',
131
+ ),
132
+ 'number_format' => array(
133
+ 'decimals' => 2,
134
+ 'decimal_point' => ',',
135
+ 'thousands_separator' => '.',
136
+ ),
114
137
));
115
138
116
139
.. caution ::
@@ -210,6 +233,37 @@ charset
210
233
The charset used by the template files. In the Symfony Standard edition this
211
234
defaults to the ``UTF-8 `` charset.
212
235
236
+ date
237
+ ~~~~
238
+
239
+ These options define the default values used by the ``date `` filter to format
240
+ date and time values. They are useful to avoid passing the same arguments on
241
+ every ``date `` filter call.
242
+
243
+ format
244
+ ......
245
+
246
+ **type **: ``string `` **default **: ``F j, Y H:i ``
247
+
248
+ The format used by the ``date `` filter to display values when no specific format
249
+ is passed as argument.
250
+
251
+ internal_format
252
+ ...............
253
+
254
+ **type **: ``string `` **default **: ``%d days ``
255
+
256
+ The format used by the ``date `` filter to display ``DateInterval `` instances
257
+ when no specific format is passed as argument.
258
+
259
+ timezone
260
+ ........
261
+
262
+ **type **: ``string `` **default **: (the value returned by ``date_default_timezone_get() ``)
263
+
264
+ The timezone used when formatting date values with the ``date `` filter and no
265
+ specific timezone is passed as argument.
266
+
213
267
debug
214
268
~~~~~
215
269
@@ -234,6 +288,38 @@ option is advanced. If you need to customize an error page you should use
234
288
the previous link. If you need to perform some behavior on an exception,
235
289
you should add a listener to the ``kernel.exception `` event (see :ref: `dic-tags-kernel-event-listener `).
236
290
291
+ number_format
292
+ ~~~~~~~~~~~~~
293
+
294
+ These options define the default values used by the ``number_format `` filter to
295
+ format numeric values. They are useful to avoid passing the same arguments on
296
+ every ``number_format `` filter call.
297
+
298
+ decimals
299
+ ........
300
+
301
+ **type **: ``integer `` **default **: ``0 ``
302
+
303
+ The number of decimals used to format numeric values when no specific number is
304
+ passed as argument to the ``number_format `` filter.
305
+
306
+ decimal_point
307
+ .............
308
+
309
+ **type **: ``string `` **default **: ``. ``
310
+
311
+ The character used to separate the decimals from the integer part of numeric
312
+ values when no specific character is passed as argument to the ``number_format ``
313
+ filter.
314
+
315
+ thousands_separator
316
+ ...................
317
+
318
+ **type **: ``string `` **default **: ``, ``
319
+
320
+ The character used to separate every group of thousands in numeric values when
321
+ no specific character is passed as argument to the ``number_format `` filter.
322
+
237
323
optimizations
238
324
~~~~~~~~~~~~~
239
325
0 commit comments