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

Breadcrumb

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

function WithTokenParser::parse

Overrides TokenParserInterface::parse

File

vendor/twig/twig/src/TokenParser/WithTokenParser.php, line 27

Class

WithTokenParser
Creates a nested scope.

Namespace

Twig\TokenParser

Code

public function parse(Token $token) : Node {
    $stream = $this->parser
        ->getStream();
    $variables = null;
    $only = false;
    if (!$stream->test(Token::BLOCK_END_TYPE)) {
        $variables = $this->parser
            ->getExpressionParser()
            ->parseExpression();
        $only = (bool) $stream->nextIf(Token::NAME_TYPE, 'only');
    }
    $stream->expect(Token::BLOCK_END_TYPE);
    $body = $this->parser
        ->subparse([
        $this,
        'decideWithEnd',
    ], true);
    $stream->expect(Token::BLOCK_END_TYPE);
    return new WithNode($body, $variables, $only, $token->getLine());
}

API Navigation

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