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);
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');
73 class_alias(
'Twig_TokenParser_Block',
'Twig\TokenParser\BlockTokenParser',
false);
Marks a section of a template as being reusable.
Represents a node in the AST.
test($type, $values=null)
Tests the current token for a type and/or a value.
$stream
PHP stream implementation.
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.
Base class for all token parsers.
parse(Twig_Token $token)
Parses a token and returns a node.
decideBlockEnd(Twig_Token $token)
Create styles array
The data for the language used.
getTag()
Gets the tag name associated with this token parser.