Skip to content

Commit

Permalink
Merge branch '1.x' into 2.x
Browse files Browse the repository at this point in the history
* 1.x:
  Environment::resolveTemplate now accepts instances of TemplateWrapper
  Change typo in documentation
  fix grammar
  • Loading branch information
fabpot committed Nov 12, 2017
2 parents 31b5778 + 9c2b1dc commit 6019605
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion doc/functions/block.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ times, use the ``block`` function:
{% block body %}{% endblock %}
The ``block`` function can also be used to display one block of another
The ``block`` function can also be used to display one block from another
template:

.. code-block:: jinja
Expand Down
12 changes: 8 additions & 4 deletions lib/Twig/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,12 @@ public function isTemplateFresh($name, $time)
/**
* Tries to load a template consecutively from an array.
*
* Similar to loadTemplate() but it also accepts Twig_Template instances and an array
* of templates where each is tried to be loaded.
* Similar to loadTemplate() but it also accepts instances of Twig_Template and
* Twig_TemplateWrapper, and an array of templates where each is tried to be loaded.
*
* @param string|Twig_Template|array $names A template or an array of templates to try consecutively
* @param string|Twig_Template|Twig_TemplateWrapper|array $names A template or an array of templates to try consecutively
*
* @return Twig_Template
* @return Twig_Template|Twig_TemplateWrapper
*
* @throws Twig_Error_Loader When none of the templates can be found
* @throws Twig_Error_Syntax When an error occurred during compilation
Expand All @@ -474,6 +474,10 @@ public function resolveTemplate($names)
return $name;
}

if ($name instanceof Twig_TemplateWrapper) {
return $name;
}

try {
return $this->loadTemplate($name);
} catch (Twig_Error_Loader $e) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Twig/Extension/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ function twig_test_empty($value)
*
* <pre>
* {# evaluates to true if the foo variable is an array or a traversable object #}
* {% if foo is traversable %}
* {% if foo is iterable %}
* {# ... #}
* {% endif %}
* </pre>
Expand Down

0 comments on commit 6019605

Please sign in to comment.