mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-17 21:07:18 +00:00
Fixed error guessing in blocks in a child template
This commit is contained in:
@@ -155,6 +155,17 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|||||||
try {
|
try {
|
||||||
$template->$block($context, $blocks);
|
$template->$block($context, $blocks);
|
||||||
} catch (Twig_Error $e) {
|
} 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;
|
throw $e;
|
||||||
} catch (Exception $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);
|
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.
|
||||||
Reference in New Issue
Block a user