Fixed error guessing for nested templates

This commit is contained in:
Martin Hasoň
2015-06-02 11:19:07 +02:00
parent d63ac2088e
commit dd1b1016a7
2 changed files with 18 additions and 1 deletions
+8 -1
View File
@@ -255,7 +255,14 @@ abstract class Twig_Template implements Twig_TemplateInterface
return $this->env->loadTemplate($template, $index);
} catch (Twig_Error $e) {
$e->setTemplateFile($templateName ? $templateName : $this->getTemplateName());
if (!$e->getTemplateFile()) {
$e->setTemplateFile($templateName ? $templateName : $this->getTemplateName());
}
if ($e->getTemplateLine()) {
throw $e;
}
if (!$line) {
$e->guess();
} else {
@@ -0,0 +1,10 @@
--TEST--
Exception for syntax error in reused template
--TEMPLATE--
{% use 'foo.twig' %}
--TEMPLATE(foo.twig)--
{% block bar %}
{% do node.data = 5 %}
{% endblock %}
--EXCEPTION--
Twig_Error_Syntax: Unexpected token "operator" of value "=" ("end of statement block" expected) in "foo.twig" at line 3