File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,34 @@ configuration, and tag it with ``twig.extension``:
82
82
For information on how to create the actual Twig Extension class, see
83
83
`Twig's documentation `_ on the topic.
84
84
85
+ Before writing your own extensions, have a look at the
86
+ `Twig official extension repository `_ which already includes several
87
+ useful extensions. For example ``Intl `` and its ``localizeddate `` filter
88
+ that formats a date according to user's locale. These official Twig extensions
89
+ also have to be added as regular services:
90
+
91
+ .. configuration-block ::
92
+
93
+ .. code-block :: yaml
94
+
95
+ services :
96
+ twig.extension.intl :
97
+ class : Twig_Extensions_Extension_Intl
98
+ tags :
99
+ - { name: twig.extension }
100
+
101
+ .. code-block :: xml
102
+
103
+ <service id =" twig.extension.intl" class =" Twig_Extensions_Extension_Intl" >
104
+ <tag name =" twig.extension" />
105
+ </service >
106
+
107
+ .. code-block :: php
108
+
109
+ $container
110
+ ->register('twig.extension.intl', 'Twig_Extensions_Extension_Intl')
111
+ ->addTag('twig.extension')
112
+ ;
85
113
86
114
.. _dic-tags-kernel-event-listener :
87
115
@@ -318,3 +346,4 @@ channel used in the Security component:
318
346
same tag as handlers are shared between all channels.
319
347
320
348
.. _`Twig's documentation` : http://twig.sensiolabs.org/doc/extensions.html
349
+ .. _`Twig official extension repository` : http://github.com/fabpot/Twig-extensions
You can’t perform that action at this time.
0 commit comments