4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
13 * Creates a nested scope.
15 * @author Fabien Potencier <fabien@symfony.com>
19 class Twig_TokenParser_With extends Twig_TokenParser
21 public function parse(Twig_Token $token)
23 $stream = $this->parser->getStream();
27 if (!$stream->test(Twig_Token::BLOCK_END_TYPE)) {
28 $variables = $this->parser->getExpressionParser()->parseExpression();
29 $only = $stream->nextIf(Twig_Token::NAME_TYPE, 'only');
32 $stream->expect(Twig_Token::BLOCK_END_TYPE);
34 $body = $this->parser->subparse(array($this, 'decideWithEnd'), true);
36 $stream->expect(Twig_Token::BLOCK_END_TYPE);
38 return new Twig_Node_With($body, $variables, $only, $token->getLine(), $this->getTag());
41 public function decideWithEnd(Twig_Token $token)
43 return $token->test('endwith');
46 public function getTag()
52 class_alias('Twig_TokenParser_With', 'Twig\TokenParser\WithTokenParser', false);