class ApplyTokenParser
Applies filters on a section of a template.
{% apply upper %} This text becomes uppercase {% endapply %}
@internal
Hierarchy
- class \Twig\TokenParser\AbstractTokenParser implements \Twig\TokenParser\TokenParserInterface
- class \Twig\TokenParser\ApplyTokenParser extends \Twig\TokenParser\AbstractTokenParser
Expanded class hierarchy of ApplyTokenParser
1 file declares its use of ApplyTokenParser
- CoreExtension.php in vendor/
twig/ twig/ src/ Extension/ CoreExtension.php
File
-
vendor/
twig/ twig/ src/ TokenParser/ ApplyTokenParser.php, line 30
Namespace
Twig\TokenParserView source
final class ApplyTokenParser extends AbstractTokenParser {
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);
}
public function decideApplyEnd(Token $token) : bool {
return $token->test('endapply');
}
public function getTag() : string {
return 'apply';
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
AbstractTokenParser::$parser | protected | property | ||
AbstractTokenParser::setParser | public | function | Sets the parser associated with this token parser. | Overrides TokenParserInterface::setParser |
ApplyTokenParser::decideApplyEnd | public | function | ||
ApplyTokenParser::getTag | public | function | Gets the tag name associated with this token parser. | Overrides TokenParserInterface::getTag |
ApplyTokenParser::parse | public | function | Parses a token and returns a node. | Overrides TokenParserInterface::parse |