@@ -26,11 +26,11 @@ Usage
26
26
27
27
The :class: `Symfony\\ Component\\ Templating\\ PhpEngine ` class is the entry point
28
28
of the component. It needs a
29
- :class: ` template name parser < Symfony\\ Component\\ Templating\\ TemplateNameParserInterface> `
29
+ template name parser ( :class: ` Symfony\\ Component\\ Templating\\ TemplateNameParserInterface `)
30
30
to convert a template name to a
31
- :class: ` template reference < Symfony\\ Component\\ Templating\\ TemplateReferenceInterface> `
32
- and :class: ` template loader < Symfony\\ Component\\ Templating\\ Loader\\ LoaderInterface> `
33
- to find the template associated to a reference ::
31
+ template reference ( :class: ` Symfony\\ Component\\ Templating\\ TemplateReferenceInterface `).
32
+ It also needs a template loader ( :class: ` Symfony\\ Component\\ Templating\\ Loader\\ LoaderInterface `)
33
+ which uses the template reference to actually find and load the template ::
34
34
35
35
use Symfony\Component\Templating\PhpEngine;
36
36
use Symfony\Component\Templating\TemplateNameParser;
@@ -57,16 +57,16 @@ The ``$view`` variable
57
57
58
58
In all templates parsed by the ``PhpEngine ``, you get access to a mysterious
59
59
variable called ``$view ``. That variable holds the current ``PhpEngine ``
60
- instance. That means you get access to a bunch of methods that makes your life
60
+ instance. That means you get access to a bunch of methods that make your life
61
61
easier.
62
62
63
63
Including Templates
64
64
-------------------
65
65
66
- The best way to share a snippet of template code is to define a template that
67
- can then be included into other templates. As the ``$view `` variable is an
66
+ The best way to share a snippet of template code is to create a template that
67
+ can then be included by other templates. As the ``$view `` variable is an
68
68
instance of ``PhpEngine ``, you can use the ``render `` method (which was used
69
- to render the template) inside the template to render another template::
69
+ to render the template originally ) inside the template to render another template::
70
70
71
71
<?php $names = array('Fabien', ...) ?>
72
72
<?php foreach ($names as $name) : ?>
@@ -76,18 +76,20 @@ to render the template) inside the template to render another template::
76
76
Output Escaping
77
77
---------------
78
78
79
- When you display variables to the user, you should escape them using the
79
+ When you render variables, you should probably escape them so that HTML or
80
+ JavaScript code isn't written out to your page. This will prevent things like
81
+ XSS attacks. To do this, use the
80
82
:method: `Symfony\\ Component\\ Templating\\ PhpEngine::escape ` method::
81
83
82
84
<?php echo $view->escape($firstname) ?>
83
85
84
86
By default, the ``escape() `` method assumes that the variable is outputted
85
87
within an HTML context. The second argument lets you change the context. For
86
- instance , to output something in a JavaScript script , use the ``js `` context::
88
+ example , to output something inside JavaScript, use the ``js `` context::
87
89
88
90
<?php echo $view->escape($var, 'js') ?>
89
91
90
- The components comes with a HTML and JS escaper. You can register your own
92
+ The component comes with an HTML and JS escaper. You can register your own
91
93
escaper using the
92
94
:method: `Symfony\\ Component\\ Templating\\ PhpEngine::setEscaper ` method::
93
95
@@ -101,10 +103,10 @@ Helpers
101
103
-------
102
104
103
105
The Templating component can be easily extended via helpers. The component has
104
- 2 build -in helpers:
106
+ 2 built -in helpers:
105
107
106
- * :doc: `/components/helpers/assetshelper `
107
- * :doc: `/components/helpers/slotshelper `
108
+ * :doc: `/components/templating/ helpers/assetshelper `
109
+ * :doc: `/components/templating/ helpers/slotshelper `
108
110
109
111
Before you can use these helpers, you need to register them using
110
112
:method: `Symfony\\ Component\\ Templating\\ PhpEngine::set `::
0 commit comments