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