From: Fabien Potencier Date: Thu, 20 May 2010 09:30:20 +0000 (+0200) Subject: added the filename when throwing an exception about a non-empty body in a child template X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=32af68d90441d7a2a3abc1837d1abd5c9cdaf94b;p=web%2Fkonrad%2Ftwig.git added the filename when throwing an exception about a non-empty body in a child template --- diff --git a/lib/Twig/Parser.php b/lib/Twig/Parser.php index 6d431ab..d3dd1d7 100644 --- a/lib/Twig/Parser.php +++ b/lib/Twig/Parser.php @@ -74,13 +74,6 @@ class Twig_Parser } if (!is_null($this->extends)) { - foreach ($this->blocks as $block) { - $block->setParent($this->extends); - } - } - - if ($this->extends) - { // check that the body only contains block references and empty text nodes foreach ($body->getNodes() as $node) { @@ -89,9 +82,13 @@ class Twig_Parser || (!$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference) ) { - throw new Twig_SyntaxError('A template that extends another one cannot have a body', $node->getLine()); + throw new Twig_SyntaxError('A template that extends another one cannot have a body', $node->getLine(), $this->stream->getFilename()); } } + + foreach ($this->blocks as $block) { + $block->setParent($this->extends); + } } $node = new Twig_Node_Module($body, $this->extends, $this->blocks, $this->macros, $this->stream->getFilename());