function ApplyTokenParser::parse
Overrides TokenParserInterface::parse
File
-
vendor/
twig/ twig/ src/ TokenParser/ ApplyTokenParser.php, line 32
Class
- ApplyTokenParser
- Applies filters on a section of a template.
Namespace
Twig\TokenParserCode
public function parse(Token $token) : Node {
$lineno = $token->getLine();
$ref = new LocalVariable(null, $lineno);
$filter = $this->parser
->getExpressionParser()
->parseFilterExpressionRaw($ref);
$this->parser
->getStream()
->expect(Token::BLOCK_END_TYPE);
$body = $this->parser
->subparse([
$this,
'decideApplyEnd',
], true);
$this->parser
->getStream()
->expect(Token::BLOCK_END_TYPE);
return new Nodes([
new SetNode(true, $ref, $body, $lineno),
new PrintNode($filter, $lineno),
], $lineno);
}