]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/twig/twig/lib/Twig/TokenParser/Filter.php
4 * This file is part of Twig.
6 * (c) 2009 Fabien Potencier
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
13 * Filters a section of a template by applying filters.
17 * This text becomes uppercase
21 class Twig_TokenParser_Filter
extends Twig_TokenParser
24 * Parses a token and returns a node.
26 * @param Twig_Token $token A Twig_Token instance
28 * @return Twig_NodeInterface A Twig_NodeInterface instance
30 public function parse(Twig_Token
$token)
32 $name = $this->parser
->getVarName();
33 $ref = new Twig_Node_Expression_BlockReference(new Twig_Node_Expression_Constant($name, $token->getLine()), true, $token->getLine(), $this->getTag());
35 $filter = $this->parser
->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag());
36 $this->parser
->getStream()->expect(Twig_Token
::BLOCK_END_TYPE
);
38 $body = $this->parser
->subparse(array($this, 'decideBlockEnd'), true);
39 $this->parser
->getStream()->expect(Twig_Token
::BLOCK_END_TYPE
);
41 $block = new Twig_Node_Block($name, $body, $token->getLine());
42 $this->parser
->setBlock($name, $block);
44 return new Twig_Node_Print($filter, $token->getLine(), $this->getTag());
47 public function decideBlockEnd(Twig_Token
$token)
49 return $token->test('endfilter');
53 * Gets the tag name associated with this token parser.
55 * @return string The tag name
57 public function getTag()