You are here

class TwigThemeTokenParser in Components! 8

Generates a render array and renders that.


 {%
   theme 'item_list' with {
     items: [],
   }
 %}

Hierarchy

  • class \Drupal\components\Template\TwigThemeTokenParser extends \Drupal\components\Template\Twig_TokenParser

Expanded class hierarchy of TwigThemeTokenParser

File

src/Template/TwigThemeTokenParser.php, line 16

Namespace

Drupal\components\Template
View source
class TwigThemeTokenParser extends \Twig_TokenParser {

  /**
   * {@inheritdoc}
   */
  public function parse(\Twig_Token $token) {
    $expr = $this->parser
      ->getExpressionParser()
      ->parseExpression();
    return new TwigNodeTheme($expr, $this
      ->parseArguments(), $token
      ->getLine(), $this
      ->getTag());
  }

  /**
   * Parses the arguments.
   *
   * @return \Twig_Node_Expression
   *   A node expression containing the variables list.
   */
  protected function parseArguments() {
    $stream = $this->parser
      ->getStream();
    $variables = NULL;
    if ($stream
      ->nextIf(\Twig_Token::NAME_TYPE, 'with')) {
      $variables = $this->parser
        ->getExpressionParser()
        ->parseExpression();
    }
    $stream
      ->expect(\Twig_Token::BLOCK_END_TYPE);
    return $variables;
  }

  /**
   * {@inheritdoc}
   */
  public function getTag() {
    return 'theme';
  }

}

Members