Fixed error guessing in blocks in a child template

This commit is contained in:
Martin Hasoň
2015-07-31 14:42:21 +02:00
parent 1ded65daeb
commit cfa14046ab
2 changed files with 26 additions and 0 deletions
+11
View File
@@ -155,6 +155,17 @@ abstract class Twig_Template implements Twig_TemplateInterface
try {
$template->$block($context, $blocks);
} catch (Twig_Error $e) {
if (!$e->getTemplateFile()) {
$e->setTemplateFile($template->getTemplateName());
}
// this is mostly useful for Twig_Error_Loader exceptions
// see Twig_Error_Loader
if (false === $e->getTemplateLine()) {
$e->setTemplateLine(-1);
$e->guess();
}
throw $e;
} catch (Exception $e) {
throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getTemplateName(), $e);
@@ -0,0 +1,15 @@
--TEST--
Exception for an undefined template in a child template
--TEMPLATE--
{% extends 'base.twig' %}
{% block sidebar %}
{{ include('include.twig') }}
{% endblock %}
--TEMPLATE(base.twig)--
{% block sidebar %}
{% endblock %}
--DATA--
return array()
--EXCEPTION--
Twig_Error_Loader: Template "include.twig" is not defined in "index.twig" at line 5.