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

Breadcrumb

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

function ImportTokenParser::parse

Overrides TokenParserInterface::parse

File

vendor/twig/twig/src/TokenParser/ImportTokenParser.php, line 29

Class

ImportTokenParser
Imports macros.

Namespace

Twig\TokenParser

Code

public function parse(Token $token) : Node {
    $macro = $this->parser
        ->getExpressionParser()
        ->parseExpression();
    $this->parser
        ->getStream()
        ->expect(Token::NAME_TYPE, 'as');
    $name = $this->parser
        ->getStream()
        ->expect(Token::NAME_TYPE)
        ->getValue();
    $var = new AssignTemplateVariable(new TemplateVariable($name, $token->getLine()), $this->parser
        ->isMainScope());
    $this->parser
        ->getStream()
        ->expect(Token::BLOCK_END_TYPE);
    $this->parser
        ->addImportedSymbol('template', $name);
    return new ImportNode($macro, $var, $token->getLine());
}

API Navigation

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