TwigThemeTokenParser.php in Components! 8
File
src/Template/TwigThemeTokenParser.php
View source
<?php
namespace Drupal\components\Template;
class TwigThemeTokenParser extends \Twig_TokenParser {
public function parse(\Twig_Token $token) {
$expr = $this->parser
->getExpressionParser()
->parseExpression();
return new TwigNodeTheme($expr, $this
->parseArguments(), $token
->getLine(), $this
->getTag());
}
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;
}
public function getTag() {
return 'theme';
}
}