Skip to content

Commit 53519c3

Browse files
committed
[templating][routing] Making minor fixes per Stof.
1 parent d48800f commit 53519c3

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

book/routing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,10 @@ Routes and Controllers
549549
Now that you've mastered the creation of routes and learned how matching
550550
takes place, the only missing piece is connecting each route to a controller.
551551

552-
.. controller-string-syntax:
552+
.. _controller-string-syntax:
553553

554-
The ``_controller`` Parameter
555-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
554+
Controller Naming Format
555+
~~~~~~~~~~~~~~~~~~~~~~~~
556556

557557
Every route *must* contain a ``_controller`` parameter, which is a special
558558
string syntax that Symfony2 translates into a PHP callable. There are two

book/templating.rst

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,15 @@ When working with template inheritance, here are some tips to keep in mind:
332332
and ``include`` it (see :ref:`including-templates`).
333333

334334
* If you need to get the content of a block from the parent template, you
335-
can use the ``{% parent %}`` tag. This is useful if you want to add to
336-
the contents of a parent block instead of completely overriding it:
335+
can use the ``{{ parent() }}`` function. This is useful if you want to add
336+
to the contents of a parent block instead of completely overriding it:
337337

338338
.. code-block:: jinja
339339
340340
{% block sidebar %}
341341
<h3>Table of Contents</h3>
342342
...
343-
{% parent %}
343+
{{ parent() }}
344344
{% endblock %}
345345
346346
.. index::
@@ -409,7 +409,7 @@ format. For more information, read the :ref:`template-formats` section.
409409
.. tip::
410410

411411
Hopefully the template naming syntax looks familiar - it's the same naming
412-
convention used to refer to `controllers </en/controllers>`.
412+
convention used to refer to :ref:`controller-string-syntax`.
413413

414414
.. tip::
415415

@@ -437,7 +437,7 @@ ease the work of the template designer. In PHP, the templating system provides
437437
an extensible *helper* system that provides useful features in a template
438438
context.
439439

440-
We've already seen a few built-in Twig tags (``{{ block }}`` & ``{{ extends }}``)
440+
We've already seen a few built-in Twig tags (``{% block %}`` & ``{% extends %}``)
441441
as well as an example of a PHP helper (``$view['slots']``). Let's learn a
442442
few more.
443443

@@ -796,27 +796,33 @@ configuration file:
796796
# app/config/config.yml
797797
framework:
798798
# ...
799-
templating: {}
799+
templating: { engines: ['twig'] }
800800
801801
.. code-block:: xml
802802
803803
<!-- app/config/config.xml -->
804-
<framework:config ...>
805-
<!-- ... -->
806-
<framework:templating />
807-
</framework:config>
804+
<framework:templating cache-warmer="true">
805+
<framework:engine id="twig" />
806+
</framework:templating>
808807
809808
.. code-block:: php
810809
811810
// app/config/config.php
812811
$container->loadFromExtension('framework', array(
813812
// ...
814-
'templating' => array(),
813+
'templating' => array(
814+
'engines' => array('twig'),
815+
),
815816
));
816817
817818
Several configuration options are available and are covered in the
818819
:ref:`Configuration Appendix<appendix-templating-configuration>`.
819820

821+
.. note::
822+
823+
The ``twig`` engine is mandatory to use the webprofiler (as well as many
824+
third-party bundles).
825+
820826
.. index::
821827
single; Template; Overriding templates
822828

@@ -856,7 +862,7 @@ in question lives at ``Resources/views/Blog/index.html.twig`` inside the
856862
template to ``app/views/BlogBundle/Blog/index.html.twig`` (the ``BlogBundle``
857863
directory might not exist). Now, when you render the ``BlogBundle:Blog:index.html.twig``
858864
template, Symfony2 will look first for the template at ``app/views/BlogBundle/Blog/index.html.twig``
859-
before looking inside ``BlogBundle``. You're know free to customize the template
865+
before looking inside ``BlogBundle``. You're now free to customize the template
860866
for your application.
861867

862868
Suppose also that each template in ``BlogBundle`` inherits from a template
@@ -942,12 +948,12 @@ a bundle can be easily overriden to properly extend your application's base
942948
layout.
943949

944950
.. index::
945-
single: Templating; Output escapgin
951+
single: Templating; Output escaping
946952

947953
Output Escaping
948954
---------------
949955

950-
When generating HTML from a template, there is awlays a risk that a template
956+
When generating HTML from a template, there is always a risk that a template
951957
variable may output unintended HTML or dangerous client-side code. The result
952958
is that dynamic content could break the HTML of the resulting page or allow
953959
a malicious user to perform a `Cross Site Scripting`_ (XSS) attack. Consider
@@ -992,15 +998,16 @@ Output Escaping in Twig
992998

993999
If you're using Twig templates, then output escaping is on by default. This
9941000
means that you're protected out-of-the-box from the unintentional consequences
995-
of user-submitted code.
1001+
of user-submitted code. By default, the output escaping assumes that content
1002+
is being escaped for HTML output.
9961003

9971004
In some cases, you'll need to disable output escaping when you're rendering
9981005
a variable that is trusted and contains markup that should not be escaped.
9991006
Suppose that administrative users are able to write articles that contain
10001007
HTML code. By default, Twig will escape the article body. To render it normally,
10011008
add the ``raw`` filter: ``{{ article.body | raw }}``.
10021009

1003-
You can also to disable output escaping inside a ``{{ block }}`` area or
1010+
You can also to disable output escaping inside a ``{% block %}`` area or
10041011
for an entire template. For more information, see `Output Escaping`_ in
10051012
the Twig documentation.
10061013

0 commit comments

Comments
 (0)