@@ -148,8 +148,8 @@ Twig Template Caching
148148Twig is fast because each template is compiled to a native PHP class and cached.
149149But don't worry: this happens automatically and doesn't require *you * to do anything.
150150And while you're developing, Twig is smart enough to re-compile your templates after
151- you make any changes. That means Twig is fast in production, but easy to use while
152- developing.
151+ you make any changes. That means Twig is fast in production, but convenient to use
152+ while developing.
153153
154154.. index ::
155155 single: Templating; Inheritance
@@ -200,12 +200,12 @@ First, build a base layout file:
200200 Though the discussion about template inheritance will be in terms of Twig,
201201 the philosophy is the same between Twig and PHP templates.
202202
203- This template defines the base HTML skeleton document of a simple two-column
203+ This template defines the base HTML skeleton document of a two-column
204204page. In this example, three ``{% block %} `` areas are defined (``title ``,
205205``sidebar `` and ``body ``). Each block may be overridden by a child template
206206or left with its default implementation. This template could also be rendered
207207directly. In that case the ``title ``, ``sidebar `` and ``body `` blocks would
208- simply retain the default values used in this template.
208+ retain the default values used in this template.
209209
210210A child template might look like this:
211211
@@ -226,7 +226,7 @@ A child template might look like this:
226226.. note ::
227227
228228 The parent template is stored in ``templates/ ``, so its path is
229- simply ``base.html.twig ``. The template naming conventions are explained
229+ ``base.html.twig ``. The template naming conventions are explained
230230 fully in :ref: `template-naming-locations `.
231231
232232The key to template inheritance is the ``{% extends %} `` tag. This tells
@@ -437,7 +437,8 @@ template. First, create the template that you'll need to reuse.
437437 {{ article.body }}
438438 </p>
439439
440- Including this template from any other template is simple:
440+ Including this template from any other template is achieved with the
441+ ``{{ include() }} `` function:
441442
442443.. code-block :: html+twig
443444
@@ -452,12 +453,11 @@ Including this template from any other template is simple:
452453 {% endfor %}
453454 {% endblock %}
454455
455- The template is included using the ``{{ include() }} `` function. Notice that the
456- template name follows the same typical convention. The ``article_details.html.twig ``
457- template uses an ``article `` variable, which we pass to it. In this case,
458- you could avoid doing this entirely, as all of the variables available in
459- ``list.html.twig `` are also available in ``article_details.html.twig `` (unless
460- you set `with_context `_ to false).
456+ Notice that the template name follows the same typical convention. The
457+ ``article_details.html.twig `` template uses an ``article `` variable, which we
458+ pass to it. In this case, you could avoid doing this entirely, as all of the
459+ variables available in ``list.html.twig `` are also available in
460+ ``article_details.html.twig `` (unless you set `with_context `_ to false).
461461
462462.. tip ::
463463
@@ -537,7 +537,7 @@ configuration:
537537
538538 return $routes;
539539
540- To link to the page, just use the ``path() `` Twig function and refer to the route:
540+ To link to the page, use the ``path() `` Twig function and refer to the route:
541541
542542.. code-block :: html+twig
543543
@@ -631,7 +631,7 @@ Linking to Assets
631631~~~~~~~~~~~~~~~~~
632632
633633Templates also commonly refer to images, JavaScript, stylesheets and other
634- assets. Of course you could hard-code the path to these assets (e.g. ``/images/logo.png ``),
634+ assets. You could hard-code the web path to these assets (e.g. ``/images/logo.png ``),
635635but Symfony provides a more dynamic option via the ``asset() `` Twig function.
636636
637637To use this function, install the *asset * package:
@@ -715,8 +715,9 @@ stylesheets and JavaScripts that you'll need throughout your site:
715715 </body>
716716 </html>
717717
718- That's easy enough! But what if you need to include an extra stylesheet or
719- JavaScript from a child template? For example, suppose you have a contact
718+ This looks almost like regular HTML, but with the addition of the
719+ ``{% block %} ``. Those are useful when you need to include an extra stylesheet
720+ or JavaScript from a child template. For example, suppose you have a contact
720721page and you need to include a ``contact.css `` stylesheet *just * on that
721722page. From inside that contact page's template, do the following:
722723
@@ -733,11 +734,11 @@ page. From inside that contact page's template, do the following:
733734
734735 {# ... #}
735736
736- In the child template, you simply override the ``stylesheets `` block and
737- put your new stylesheet tag inside of that block. Of course, since you want
738- to add to the parent block's content (and not actually *replace * it), you
739- should use the `` parent() `` Twig function to include everything from the ``stylesheets ``
740- block of the base template.
737+ In the child template, you override the ``stylesheets `` block and put your new
738+ stylesheet tag inside of that block. Since you want to add to the parent
739+ block's content (and not actually *replace * it), you also use the `` parent() ``
740+ Twig function to include everything from the ``stylesheets `` block of the base
741+ template.
741742
742743You can also include assets located in your bundles' ``Resources/public/ `` folder.
743744You will need to run the ``php bin/console assets:install target [--symlink] ``
0 commit comments