35 $stream = $this->parser->getStream();
37 if ($this->parser->hasBlock($name)) {
38 throw new Twig_Error_Syntax(sprintf(
"The block '$name' has already been defined line %d", $this->parser->getBlock($name)->getLine()), $stream->getCurrent()->getLine(), $stream->getFilename());
41 $this->parser->pushLocalScope();
42 $this->parser->pushBlockStack($name);
47 $body = $this->parser->subparse(array($this,
'decideBlockEnd'),
true);
49 $value = $stream->next()->getValue();
51 if ($value != $name) {
52 throw new Twig_Error_Syntax(sprintf(
"Expected endblock for block '$name' (but %s given)", $value), $stream->getCurrent()->getLine(), $stream->getFilename());
57 new Twig_Node_Print($this->parser->getExpressionParser()->parseExpression(), $lineno),
63 $this->parser->popBlockStack();
64 $this->parser->popLocalScope();
71 return $token->
test(
'endblock');
Base class for all token parsers.
setNode($name, $node=null)
Sets a node.
Represents a node in the AST.
Exception thrown when a syntax error occurs during lexing or parsing of a template.
Represents a block call node.
getTag()
Gets the tag name associated with this token parser.
parse(Twig_Token $token)
Parses a token and returns a node.
decideBlockEnd(Twig_Token $token)
test($type, $values=null)
Tests the current token for a type and/or a value.
Marks a section of a template as being reusable.
Represents a node that outputs an expression.