* 1.7.0 (2012-XX-XX)
+ * added an error when defining two blocks with the same name in a template
* fixed a PHP notice when trying to access a key on a non-object/array variable
* enhanced error reporting when the template file is an instance of SplFileInfo
* added Twig_Environment::mergeGlobals()
return isset($this->blocks[$name]);
}
+ public function getBlock($name)
+ {
+ return $this->blocks[$name];
+ }
+
public function setBlock($name, $value)
{
- $this->blocks[$name] = new Twig_Node_Body(array($value));
+ $this->blocks[$name] = new Twig_Node_Body(array($value), array(), $value->getLine());
}
public function hasMacro($name)
$stream = $this->parser->getStream();
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
if ($this->parser->hasBlock($name)) {
- throw new Twig_Error_Syntax("The block '$name' has already been defined", $lineno);
+ throw new Twig_Error_Syntax(sprintf("The block '$name' has already been defined line %d", $this->parser->getBlock($name)->getLine()), $lineno);
}
+ $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno));
$this->parser->pushLocalScope();
$this->parser->pushBlockStack($name);
}
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- $block = new Twig_Node_Block($name, $body, $lineno);
- $this->parser->setBlock($name, $block);
+ $block->setNode('body', $body);
$this->parser->popBlockStack();
$this->parser->popLocalScope();