File tree Expand file tree Collapse file tree 5 files changed +23
-7
lines changed
Filter options
Expand file tree Collapse file tree 5 files changed +23
-7
lines changed
Original file line number Diff line number Diff line change 1
1
* **Templating**:
2
2
3
- * :doc:`/guides/templating/helpers ` |
4
- * :doc:`Twig < / guides/templating/Twig > `
3
+ * :doc:`Twig < / guides/templating/Twig > ` |
4
+ * :doc:`/guides/templating/helpers `
5
5
6
6
* **Doctrine**:
7
7
Original file line number Diff line number Diff line change @@ -158,6 +158,12 @@ specialized tags:
158
158
{# embed another controller response #}
159
159
{% render 'BlogBundle:Post:list' with ['limit': 2], ['alt': 'BlogBundle:Post:error'] %}
160
160
161
+ Output Escaping
162
+ ---------------
163
+
164
+ Twig is configured to automatically escapes all output by default. Read Twig
165
+ documentation to learn more about output escaping and the Escaper extension.
166
+
161
167
.. _twig_extension_tag :
162
168
163
169
Enabling Custom Twig Extensions
Original file line number Diff line number Diff line change @@ -4,6 +4,5 @@ Templating
4
4
.. toctree ::
5
5
:maxdepth: 2
6
6
7
- overview
8
- helpers
9
7
Twig
8
+ helpers
Original file line number Diff line number Diff line change @@ -176,7 +176,6 @@ PHP. Have a look at the default configuration:
176
176
router : { resource: "%kernel.root_dir%/config/routing.yml" }
177
177
validation : { enabled: true, annotations: true }
178
178
templating :
179
- escaping : htmlspecialchars
180
179
# assets_version: SomeVersionScheme
181
180
session :
182
181
default_locale : en
@@ -208,7 +207,6 @@ PHP. Have a look at the default configuration:
208
207
<app : config csrf-secret =" xxxxxxxxxx" charset =" UTF-8" error-handler =" null" >
209
208
<app : router resource =" %kernel.root_dir%/config/routing.xml" />
210
209
<app : validation enabled =" true" annotations =" true" />
211
- <app : templating escaping =" htmlspecialchars" />
212
210
<app : session default-locale =" en" lifetime =" 3600" />
213
211
</app : config >
214
212
@@ -244,7 +242,6 @@ PHP. Have a look at the default configuration:
244
242
'router' => array('resource' => '%kernel.root_dir%/config/routing.php'),
245
243
'validation' => array('enabled' => true, 'annotations' => true),
246
244
'templating' => array(
247
- 'escaping' => 'htmlspecialchars'
248
245
#'assets_version' => "SomeVersionScheme",
249
246
),
250
247
'session' => array(
Original file line number Diff line number Diff line change @@ -254,6 +254,20 @@ need to also add the following code in your main layout:
254
254
<?php echo $view['javascripts'] ?>
255
255
<?php echo $view['stylesheets'] ?>
256
256
257
+ Output Escaping
258
+ ---------------
259
+
260
+ When using PHP templates, escape variables whenever they are displayed to the
261
+ user::
262
+
263
+ <?php echo $view->escape($var) ?>
264
+
265
+ By default, the ``escape() `` method assumes that the variable is outputted
266
+ within an HTML context. The second argument lets you change the context. For
267
+ instance, to output something in a JavaScript script, use the ``js `` context::
268
+
269
+ <?php echo $view->escape($var, 'js') ?>
270
+
257
271
Final Thoughts
258
272
--------------
259
273
You can’t perform that action at this time.
0 commit comments