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 * Filters a section of a template by applying filters.
17 * This text becomes uppercase
23 class Twig_TokenParser_Filter extends Twig_TokenParser
25 public function parse(Twig_Token $token)
27 $name = $this->parser->getVarName();
28 $ref = new Twig_Node_Expression_BlockReference(new Twig_Node_Expression_Constant($name, $token->getLine()), null, $token->getLine(), $this->getTag());
30 $filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag());
31 $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
33 $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
34 $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
36 $block = new Twig_Node_Block($name, $body, $token->getLine());
37 $this->parser->setBlock($name, $block);
39 return new Twig_Node_Print($filter, $token->getLine(), $this->getTag());
42 public function decideBlockEnd(Twig_Token $token)
44 return $token->test('endfilter');
47 public function getTag()
53 class_alias('Twig_TokenParser_Filter', 'Twig\TokenParser\FilterTokenParser', false);