public function 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

Overrides Twig_TokenParserInterface::parse

File

drupal/core/vendor/twig/twig/lib/Twig/TokenParser/Filter.php, line 30

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());
}