From: nikic <+@ni-po.com> Date: Wed, 29 Dec 2010 17:45:22 +0000 (+0100) Subject: update include doc to use hashes and the current Environment API X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=8bdf02ad7d565221bc5ca629d701ee4e6509190b;p=web%2Fkonrad%2Ftwig.git update include doc to use hashes and the current Environment API --- diff --git a/doc/templates.rst b/doc/templates.rst index 5a4457b..589e799 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -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 ~~~~~~