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