update include doc to use hashes and the current Environment API

This commit is contained in:
nikic
2010-12-29 18:45:22 +01:00
committed by Fabien Potencier
parent dee2656c9d
commit 8bdf02ad7d
+4 -4
View File
@@ -794,7 +794,7 @@ You can add additional variables by passing them after the ``with`` keyword:
.. code-block:: jinja
{# the foo template will have access to the variables from the current context and the foo one #}
{% include 'foo' with ['foo': 'bar'] %}
{% include 'foo' with {'foo': 'bar'} %}
{% set vars = {'foo': 'bar'} %}
{% include 'foo' with vars %}
@@ -804,7 +804,7 @@ You can disable access to the context by appending the ``only`` keyword:
.. code-block:: jinja
{# only the foo variable will be accessible #}
{% include 'foo' with ['foo': 'bar'] only %}
{% include 'foo' with {'foo': 'bar'} only %}
.. code-block:: jinja
@@ -828,14 +828,14 @@ The template name can be any valid Twig expression:
{% include some_var %}
{% include ajax ? 'ajax.html' : 'not_ajax.html' %}
And if the variable evaluates to a ``Twig_Template`` object, Twig will use it
And if the expression evaluates to a ``Twig_Template`` object, Twig will use it
directly::
// {% include template %}
$template = $twig->loadTemplate('some_template.twig');
$twig->display('template.twig', array('template' => $template));
$twig->loadTemplate('template.twig')->display(array('template' => $template));
Import
~~~~~~