public function Twig_TokenParser_Filter::parse in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/twig/twig/lib/Twig/TokenParser/Filter.php \Twig_TokenParser_Filter::parse()
Parses a token and returns a node.
Parameters
Twig_Token $token A Twig_Token instance:
Return value
Twig_NodeInterface A Twig_NodeInterface instance
Throws
Overrides Twig_TokenParserInterface::parse
File
- vendor/
twig/ twig/ lib/ Twig/ TokenParser/ Filter.php, line 23
Class
- Twig_TokenParser_Filter
- Filters a section of a template by applying filters.
Code
public function parse(Twig_Token $token) {
$name = $this->parser
->getVarName();
$ref = new Twig_Node_Expression_BlockReference(new Twig_Node_Expression_Constant($name, $token
->getLine()), true, $token
->getLine(), $this
->getTag());
$filter = $this->parser
->getExpressionParser()
->parseFilterExpressionRaw($ref, $this
->getTag());
$this->parser
->getStream()
->expect(Twig_Token::BLOCK_END_TYPE);
$body = $this->parser
->subparse(array(
$this,
'decideBlockEnd',
), true);
$this->parser
->getStream()
->expect(Twig_Token::BLOCK_END_TYPE);
$block = new Twig_Node_Block($name, $body, $token
->getLine());
$this->parser
->setBlock($name, $block);
return new Twig_Node_Print($filter, $token
->getLine(), $this
->getTag());
}