mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 19:36:43 +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 {
|
||||
$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.
|
||||
Reference in New Issue
Block a user