@@ -112,6 +112,35 @@ If ``true``, whenever a template is rendered, Symfony checks first if its source
112
112
code has changed since it was compiled. If it has changed, the template is
113
113
compiled again automatically.
114
114
115
+ autoescape
116
+ ~~~~~~~~~~
117
+
118
+ **type **: ``boolean `` or ``string `` **default **: ``'filename' ``
119
+
120
+ If set to ``true ``, all template contents are escaped for HTML. If set to
121
+ ``false ``, automatic escaping is disabled (you can still escape each content
122
+ individually in the templates).
123
+
124
+ .. caution ::
125
+
126
+ Setting this option to ``false `` is dangerous and it will make your
127
+ application vulnerable to XSS exploits because most third-party bundles
128
+ assume that auto-escaping is enabled and they don't escape contents
129
+ themselves.
130
+
131
+ If set to a string, the template contents are escaped using the strategy with
132
+ that name. Allowed values are ``html ``, ``js ``, ``css ``, ``url ``, ``html_attr ``
133
+ and ``filename ``. The default value is ``filename `` and it escapes contents
134
+ according to the filename extension (e.g. it uses ``html `` for ``*.html.twig ``
135
+ templates and ``js `` for ``*.js.html `` templates).
136
+
137
+ .. tip ::
138
+
139
+ See :ref: `config-twig-autoescape-service ` and :ref: `config-twig-autoescape-service-method `
140
+ to define your own escaping strategy.
141
+
142
+ .. _config-twig-autoescape-service :
143
+
115
144
autoescape_service
116
145
~~~~~~~~~~~~~~~~~~
117
146
@@ -125,6 +154,8 @@ for HTML and the contents of ``*.js.twig`` are escaped for JavaScript.
125
154
This option allows to define the Symfony service which will be used to determine
126
155
the default escaping applied to the template.
127
156
157
+ .. _config-twig-autoescape-service-method :
158
+
128
159
autoescape_service_method
129
160
~~~~~~~~~~~~~~~~~~~~~~~~~
130
161
0 commit comments