Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ApplyTokenParser.php

function ApplyTokenParser::parse

Overrides TokenParserInterface::parse

File

vendor/twig/twig/src/TokenParser/ApplyTokenParser.php, line 32

Class

ApplyTokenParser
Applies filters on a section of a template.

Namespace

Twig\TokenParser

Code

public function parse(Token $token) : Node {
    $lineno = $token->getLine();
    $ref = new LocalVariable(null, $lineno);
    $filter = $this->parser
        ->getExpressionParser()
        ->parseFilterExpressionRaw($ref);
    $this->parser
        ->getStream()
        ->expect(Token::BLOCK_END_TYPE);
    $body = $this->parser
        ->subparse([
        $this,
        'decideApplyEnd',
    ], true);
    $this->parser
        ->getStream()
        ->expect(Token::BLOCK_END_TYPE);
    return new Nodes([
        new SetNode(true, $ref, $body, $lineno),
        new PrintNode($filter, $lineno),
    ], $lineno);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal