ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AutoEscape.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
33{
34 public function parse(Twig_Token $token)
35 {
36 $lineno = $token->getLine();
37 $stream = $this->parser->getStream();
38
40 $value = 'html';
41 } else {
42 $expr = $this->parser->getExpressionParser()->parseExpression();
43 if (!$expr instanceof Twig_Node_Expression_Constant) {
44 throw new Twig_Error_Syntax('An escaping strategy must be a string or a bool.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
45 }
46 $value = $expr->getAttribute('value');
47
48 $compat = true === $value || false === $value;
49
50 if (true === $value) {
51 $value = 'html';
52 }
53
55 @trigger_error('Using the autoescape tag with "true" or "false" before the strategy name is deprecated since version 1.21.', E_USER_DEPRECATED);
56
57 if (false === $value) {
58 throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
59 }
60
61 $value = $stream->next()->getValue();
62 }
63 }
64
66 $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
68
69 return new Twig_Node_AutoEscape($value, $body, $lineno, $this->getTag());
70 }
71
73 {
74 return $token->test('endautoescape');
75 }
76
77 public function getTag()
78 {
79 return 'autoescape';
80 }
81}
82
83class_alias('Twig_TokenParser_AutoEscape', 'Twig\TokenParser\AutoEscapeTokenParser', 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.
Definition: Syntax.php:19
Represents an autoescape node.
Definition: AutoEscape.php:24
Marks a section of a template to be escaped or not.
Definition: AutoEscape.php:33
getTag()
Gets the tag name associated with this token parser.
Definition: AutoEscape.php:77
decideBlockEnd(Twig_Token $token)
Definition: AutoEscape.php:72
parse(Twig_Token $token)
Parses a token and returns a node.
Definition: AutoEscape.php:34
Base class for all token parsers.
Definition: TokenParser.php:18
Represents a Token.
Definition: Token.php:21
const BLOCK_END_TYPE
Definition: Token.php:30
const NAME_TYPE
Definition: Token.php:32
$stream
PHP stream implementation.