29 $lineno =
$token->getLine();
30 $stream = $this->parser->getStream();
32 if ($this->parser->hasBlock(
$name)) {
33 throw new Twig_Error_Syntax(sprintf(
"The block '%s' has already been defined line %d.",
$name, $this->parser->getBlock(
$name)->getTemplateLine()),
$stream->getCurrent()->getLine(),
$stream->getSourceContext());
36 $this->parser->pushLocalScope();
37 $this->parser->pushBlockStack(
$name);
40 $body = $this->parser->subparse(array($this,
'decideBlockEnd'),
true);
42 $value =
$token->getValue();
44 if ($value !=
$name) {
50 new Twig_Node_Print($this->parser->getExpressionParser()->parseExpression(), $lineno),
55 $block->setNode(
'body', $body);
56 $this->parser->popBlockStack();
57 $this->parser->popLocalScope();
64 return $token->test(
'endblock');
73class_alias(
'Twig_TokenParser_Block',
'Twig\TokenParser\BlockTokenParser',
false);
An exception for terminatinating execution or to throw for unit testing.
Exception thrown when a syntax error occurs during lexing or parsing of a template.
Represents a block call node.
Represents a node that outputs an expression.
Represents a node in the AST.
Marks a section of a template as being reusable.
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)
Base class for all token parsers.
$stream
PHP stream implementation.