Skip to content

Commit d1ca623

Browse files
committed
[symfony#2813] Tweaks to explaining how variables are passed into included templates and making references to older include tag easier to get more information about
1 parent 08f682e commit d1ca623

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

book/templating.rst

+9-6
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,10 @@ Including this template from any other template is simple:
561561

562562
The template is included using the ``{{ include() }}`` function. Notice that the
563563
template name follows the same typical convention. The ``articleDetails.html.twig``
564-
template uses an ``article`` variable. This could be passed in by the ``list.html.twig``
565-
template using the ``with`` command supported on a twig ``include`` tag. In this
566-
case however, we chose to use the twig ``include`` function which also passes context
567-
by default and passes also optional hashes however without the need for a ``with`` keyword.
564+
template uses an ``article`` variable, which we pass to it. In this case,
565+
you could avoid doing this entirely, as all of the variables available in
566+
``list.html.twig`` are also available in ``articleDetails.html.twig`` (unless
567+
you set `with_context<twig_include_function>`_ to false).
568568

569569
.. tip::
570570

@@ -573,8 +573,9 @@ by default and passes also optional hashes however without the need for a ``with
573573
elements, it would look like this: ``{'foo': foo, 'bar': bar}``.
574574

575575
.. versionadded:: 2.2
576-
The ``include()`` function is a new Twig feature that's available in
577-
Symfony 2.2. Prior, the ``{% include %}`` tag was used.
576+
The `include()<twig_include_function>`_ function is a new Twig feature
577+
that's available in Symfony 2.2. Prior, the `{% include %}<twig_include_tag>`_
578+
tag was used.
578579

579580
.. index::
580581
single: Templating; Embedding action
@@ -1537,3 +1538,5 @@ Learn more from the Cookbook
15371538
.. _`filters`: http://twig.sensiolabs.org/doc/filters/index.html
15381539
.. _`add your own extensions`: http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension
15391540
.. _`hinclude.js`: http://mnot.github.com/hinclude/
1541+
.. _`twig_include_function`: http://twig.sensiolabs.org/doc/functions/include.html
1542+
.. _`twig_include_tag`: http://twig.sensiolabs.org/doc/tags/include.html

0 commit comments

Comments
 (0)