class AutoEscapeTokenParser
Marks a section of a template to be escaped or not.
@internal
Hierarchy
- class \Twig\TokenParser\AbstractTokenParser implements \Twig\TokenParser\TokenParserInterface
- class \Twig\TokenParser\AutoEscapeTokenParser extends \Twig\TokenParser\AbstractTokenParser
Expanded class hierarchy of AutoEscapeTokenParser
1 file declares its use of AutoEscapeTokenParser
- EscaperExtension.php in vendor/
twig/ twig/ src/ Extension/ EscaperExtension.php
File
-
vendor/
twig/ twig/ src/ TokenParser/ AutoEscapeTokenParser.php, line 25
Namespace
Twig\TokenParserView source
final class AutoEscapeTokenParser extends AbstractTokenParser {
public function parse(Token $token) : Node {
$lineno = $token->getLine();
$stream = $this->parser
->getStream();
if ($stream->test(Token::BLOCK_END_TYPE)) {
$value = 'html';
}
else {
$expr = $this->parser
->getExpressionParser()
->parseExpression();
if (!$expr instanceof ConstantExpression) {
throw new SyntaxError('An escaping strategy must be a string or false.', $stream->getCurrent()
->getLine(), $stream->getSourceContext());
}
$value = $expr->getAttribute('value');
}
$stream->expect(Token::BLOCK_END_TYPE);
$body = $this->parser
->subparse([
$this,
'decideBlockEnd',
], true);
$stream->expect(Token::BLOCK_END_TYPE);
return new AutoEscapeNode($value, $body, $lineno);
}
public function decideBlockEnd(Token $token) : bool {
return $token->test('endautoescape');
}
public function getTag() : string {
return 'autoescape';
}
}
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 |
AutoEscapeTokenParser::decideBlockEnd | public | function | ||
AutoEscapeTokenParser::getTag | public | function | Gets the tag name associated with this token parser. | Overrides TokenParserInterface::getTag |
AutoEscapeTokenParser::parse | public | function | Parses a token and returns a node. | Overrides TokenParserInterface::parse |