예제 #1
1
 /**
  * Parses a token and returns a node.
  *
  * @param  \Twig_Token $token A Twig_Token instance
  *
  * @return \Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(\Twig_Token $token)
 {
     $lineno = $token->getLine();
     $stream = $this->parser->getStream();
     $vars = new \Twig_Node_Expression_Array(array(), $lineno);
     $body = null;
     $count = $this->parser->getExpressionParser()->parseExpression();
     $domain = new \Twig_Node_Expression_Constant('messages', $lineno);
     if (!$stream->test(\Twig_Token::BLOCK_END_TYPE) && $stream->test('for')) {
         // {% transchoice count for "message" %}
         // {% transchoice count for message %}
         $stream->next();
         $body = $this->parser->getExpressionParser()->parseExpression();
     }
     if ($stream->test('with')) {
         // {% transchoice count with vars %}
         $stream->next();
         $vars = $this->parser->getExpressionParser()->parseExpression();
     }
     if ($stream->test('from')) {
         // {% transchoice count from "messages" %}
         $stream->next();
         $domain = $this->parser->getExpressionParser()->parseExpression();
     }
     if (null === $body) {
         // {% transchoice count %}message{% endtranschoice %}
         $stream->expect(\Twig_Token::BLOCK_END_TYPE);
         $body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
     }
     if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
         throw new \Twig_Error_Syntax(sprintf('A message must be a simple text (line %s)', $lineno), -1);
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return new TransNode($body, $domain, $count, $vars, $lineno, $this->getTag());
 }
예제 #2
0
 /**
  * {@inheritDoc}
  */
 public function parse(\Twig_Token $token)
 {
     $stream = $this->parser->getStream();
     $expressionParser = $this->parser->getExpressionParser();
     if ($stream->test(\Twig_Token::NAME_TYPE)) {
         $currentToken = $stream->getCurrent();
         $currentValue = $currentToken->getValue();
         $currentLine = $currentToken->getLine();
         // Creates expression: placeholder_name|default('placeholder_name')
         // To parse either variable value or name
         $name = new \Twig_Node_Expression_Filter_Default(new \Twig_Node_Expression_Name($currentValue, $currentLine), new \Twig_Node_Expression_Constant('default', $currentLine), new \Twig_Node(array(new \Twig_Node_Expression_Constant($currentValue, $currentLine)), array(), $currentLine), $currentLine);
         $stream->next();
     } else {
         $name = $expressionParser->parseExpression();
     }
     if ($stream->nextIf(\Twig_Token::NAME_TYPE, 'with')) {
         $variables = $expressionParser->parseExpression();
     } else {
         $variables = new \Twig_Node_Expression_Constant(array(), $token->getLine());
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     // build expression to call 'placeholder' function
     $expr = new \Twig_Node_Expression_Function('placeholder', new \Twig_Node(array('name' => $name, 'variables' => $variables)), $token->getLine());
     return new \Twig_Node_Print($expr, $token->getLine(), $this->getTag());
 }
예제 #3
0
파일: From.php 프로젝트: idwsdta/INIT-frame
 public function parse(Twig_Token $token)
 {
     $macro = $this->parser->getExpressionParser()->parseExpression();
     $stream = $this->parser->getStream();
     $stream->expect('import');
     $targets = array();
     do {
         $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
         $alias = $name;
         if ($stream->nextIf('as')) {
             $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
         }
         $targets[$name] = $alias;
         if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
             break;
         }
     } while (true);
     $stream->expect(Twig_Token::BLOCK_END_TYPE);
     $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag());
     foreach ($targets as $name => $alias) {
         if ($this->parser->isReservedMacroName($name)) {
             throw new Twig_Error_Syntax(sprintf('"%s" cannot be an imported macro as it is a reserved keyword.', $name), $token->getLine(), $stream->getFilename());
         }
         $this->parser->addImportedSymbol('function', $alias, 'get' . $name, $node->getNode('var'));
     }
     return $node;
 }
예제 #4
0
 /**
  * Parses a token and returns a node.
  *
  * @param Twig_Token $token A Twig_Token instance
  *
  * @return Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(\Twig_Token $token)
 {
     $lineno = $token->getLine();
     $stream = $this->parser->getStream();
     $test_name = $stream->expect(\Twig_Token::NAME_TYPE)->getValue();
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $test_name = preg_replace("/[^a-zA-Z0-9]+/", "", $test_name);
     $variants = [];
     // Find the first variant name, and discard content before it.
     $this->parser->subparse(array($this, 'decideIfVariant'));
     // Parse the available variants
     $end = false;
     while (!$end) {
         switch ($stream->next()->getValue()) {
             case 'variant':
                 $name = $stream->expect(\Twig_Token::NAME_TYPE)->getValue();
                 $stream->expect(\Twig_Token::BLOCK_END_TYPE);
                 $body = $this->parser->subparse(array($this, 'decideIfVariant'));
                 $name = preg_replace("/[^a-zA-Z0-9]+/", "", $name);
                 $variants[$name] = $body;
                 break;
             case 'endab':
                 $end = true;
                 break;
             default:
                 throw new \Twig_Error_Syntax(sprintf('ab block started on line %d was not closed.)', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename());
         }
     }
     if (count($variants) < 1) {
         throw new \Twig_Error_Syntax(sprintf('ab block started on line %d had no variants.)', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename());
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return new Node($test_name, $variants, $token->getLine(), $this->getTag());
 }
 /**
  * Parses a token and returns a node.
  *
  * @param Twig_Token $token A Twig_Token instance
  *
  * @return Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(Twig_Token $token)
 {
     $macro = $this->parser->getExpressionParser()->parseExpression();
     $stream = $this->parser->getStream();
     $stream->expect('import');
     $targets = array();
     do {
         $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
         $alias = $name;
         if ($stream->test('as')) {
             $stream->next();
             $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
         }
         $targets[$name] = $alias;
         if (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ',')) {
             break;
         }
         $stream->next();
     } while (true);
     $stream->expect(Twig_Token::BLOCK_END_TYPE);
     $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag());
     foreach ($targets as $name => $alias) {
         $this->parser->addImportedFunction($alias, $name, $node->getNode('var'));
     }
     return $node;
 }
예제 #6
0
 /**
  * Parses a token and returns a node.
  *
  * @param Twig_Token $token A Twig_Token instance
  *
  * @return Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(Twig_Token $token)
 {
     $macro = $this->parser->getExpressionParser()->parseExpression();
     $this->parser->getStream()->expect('as');
     $var = new Twig_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(), $token->getLine());
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag());
 }
예제 #7
0
파일: Parent.php 프로젝트: skoop/MediTerra
 public function parse(Twig_Token $token)
 {
     if (!count($this->parser->getBlockStack())) {
         throw new Twig_SyntaxError('Calling "parent" outside a block is forbidden', $token->getLine());
     }
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     return new Twig_Node_Parent($this->parser->peekBlockStack(), $token->getLine(), $this->getTag());
 }
예제 #8
0
 public function parse(Twig_Token $token)
 {
     $helper = $token->getValue();
     $args = $this->parser->getExpressionParser()->parseArguments();
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     $expr = new Zwig_Node_Expression_ViewHelper($helper, $args, $token->getLine(), $this->getTag());
     return new Zwig_Node_Stmt($expr, array(), $token->getLine(), $this->getTag());
 }
예제 #9
0
 /**
  * Parse tag.
  *
  * @param Twig_Token $token
  * @return Twig_Node
  */
 public function parse(Twig_Token $token)
 {
     $name = $this->parser->getExpressionParser()->parseExpression();
     if (!$name instanceof Twig_Node_Expression_Constant) {
         throw new Twig_Error_Syntax('The name in a "placeholder" statement must be a string.', $token->getLine());
     }
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     return new Curry_Twig_Node_Placeholder($name->getAttribute('value'), $token->getLine(), $this->getTag());
 }
예제 #10
0
 /**
  * @param \Twig_Token $token consumed token by the lexer.
  *
  * @return \Twig_Node
  * @throws \Twig_Error_Syntax
  */
 public function parse(\Twig_Token $token)
 {
     $stream = $this->parser->getStream();
     $field = $stream->expect(\Twig_Token::NAME_TYPE)->getValue();
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     if (FormState::$current === null) {
         throw new \Twig_Error_Syntax(sprintf('Cannot render form field [%s] outside a form element', $field), $token->getLine(), $this->parser->getFilename());
     }
     return new FormFieldNode(FormState::$current, $field, $token->getLine(), $this->getTag());
 }
예제 #11
0
 public function parse(Twig_Token $token)
 {
     if (!$this->parser->isMainScope()) {
         throw new Twig_Error_Syntax('Cannot extend from a block.', $token->getLine(), $this->parser->getFilename());
     }
     if (null !== $this->parser->getParent()) {
         throw new Twig_Error_Syntax('Multiple extends tags are forbidden.', $token->getLine(), $this->parser->getFilename());
     }
     $this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
 }
예제 #12
0
 /**
  * Parses a token and returns a node.
  *
  * @param Twig_Token $token A Twig_Token instance
  *
  * @return Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(Twig_Token $token)
 {
     if (!count($this->parser->getBlockStack())) {
         throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden', $token->getLine());
     }
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     if (!$this->parser->getParent()) {
         throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend another one is forbidden', $token->getLine());
     }
     return new Twig_Node_Parent($this->parser->peekBlockStack(), $token->getLine(), $this->getTag());
 }
 /**
  * Parses a token and returns a node.
  *
  * @param \Twig_Token $token A \Twig_Token instance
  *
  * @return \Twig_NodeInterface A \Twig_NodeInterface instance
  */
 public function parse(\Twig_Token $token)
 {
     if (null !== $this->parser->getParent()) {
         throw new \Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine());
     }
     $tpl = $this->container->getParameter($this->parser->getCurrentToken()->getValue());
     $this->parser->getExpressionParser()->parseExpression();
     $this->parser->setParent(new \Twig_Node_Expression_Constant($tpl, $token->getLine()));
     $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
     return null;
 }
예제 #14
0
파일: Asset.php 프로젝트: Briareos/Undine
 /**
  * {@inheritdoc}
  */
 public function parse(\Twig_Token $token)
 {
     $stream = $this->parser->getStream();
     $stream->getCurrent()->test('string');
     $assetName = $stream->getCurrent()->getValue();
     $stream->expect(\Twig_Token::STRING_TYPE);
     $assetStore = $stream->next()->getValue();
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $asset = $this->extractAssetPath($assetName, $assetStore);
     /* @noinspection PhpParamsInspection */
     return new \Twig_Node_Print(new \Twig_Node_Expression_Constant($asset, $token->getLine()), $token->getLine(), $this->getTag());
 }
예제 #15
0
 /**
  * @param \Twig_Token $token
  *
  * @return \Twig_Node
  * @throws \Twig_Error_Syntax
  */
 public function parse(\Twig_Token $token)
 {
     $stream = $this->parser->getStream();
     $form = $stream->expect(\Twig_Token::NAME_TYPE)->getValue();
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     if (FormState::$current !== null) {
         throw new \Twig_Error_Syntax(sprintf('form [%s] not closed while opening form [%s]', FormState::$current, $form), $token->getLine(), $stream->getFilename());
     } else {
         FormState::$current = $form;
     }
     return new FormNode($form, $token->getLine(), $this->getTag());
 }
 /**
  * Parses a token and returns a node.
  *
  * @param \Twig_Token $token A \Twig_Token instance
  *
  * @return \Twig_NodeInterface A \Twig_NodeInterface instance
  */
 public function parse(\Twig_Token $token)
 {
     if (null !== $this->parser->getParent()) {
         throw new \Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine());
     }
     list($bundle, $folder, $file) = explode(':', $this->parser->getCurrentToken()->getValue());
     $path = "Admingenerated/{$bundle}/Resources/views/{$folder}/{$file}";
     $value = $this->parser->getExpressionParser()->parseExpression();
     $this->parser->setParent(new \Twig_Node_Expression_Constant($path, $token->getLine()));
     $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
     return null;
 }
예제 #17
0
 /**
  * Parses a token and returns a node.
  *
  * @param  Twig_Token $token A Twig_Token instance
  * @return Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(Twig_Token $token)
 {
     // options
     if ($this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, ',')) {
         $this->parser->getStream()->next();
         $options = $this->parser->getExpressionParser()->parseExpression();
     } else {
         $options = new Twig_Node_Expression_Array(array(), $token->getLine());
     }
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     return new Ano_ZFTwig_Node_MetaNode($options, $token->getLine(), $this->getTag());
 }
예제 #18
0
 /**
  * Parses a token and returns a node.
  *
  * @param Twig_Token $token A Twig_Token instance
  *
  * @return Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(Twig_Token $token)
 {
     $name = $this->parser->getVarName();
     $ref = new Twig_Node_Expression_BlockReference(new Twig_Node_Expression_Constant($name, $token->getLine()), true, $token->getLine(), $this->getTag());
     $filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag());
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     $block = new Twig_Node_Block($name, $body, $token->getLine());
     $this->parser->setBlock($name, $block);
     return new Twig_Node_Print($filter, $token->getLine(), $this->getTag());
 }
예제 #19
0
 /**
  * @param \Twig_Token $token consumed token by the lexer.
  *
  * @return \Twig_Node
  * @throws \Twig_Error_Syntax
  */
 public function parse(\Twig_Token $token)
 {
     $stream = $this->parser->getStream();
     if ($stream->getCurrent()->getType() != \Twig_Token::BLOCK_END_TYPE) {
         $error = sprintf("'%s' does not require any arguments.", $this->getTag());
         throw new \Twig_Error_Syntax($error, $token->getLine(), $this->parser->getFilename());
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     if (FormState::$current === null) {
         throw new \Twig_Error_Syntax(sprintf('Cannot render seo outside a form element'), $token->getLine(), $this->parser->getFilename());
     }
     return new SeoFormNode(FormState::$current, $token->getLine(), $this->getTag());
 }
예제 #20
0
 public function parse(\Twig_Token $token)
 {
     $expr = $this->parser->getExpressionParser()->parseExpression();
     // options
     if ($this->parser->getStream()->test(\Twig_Token::PUNCTUATION_TYPE, ',')) {
         $this->parser->getStream()->next();
         $options = $this->parser->getExpressionParser()->parseExpression();
     } else {
         $options = new \Twig_Node_Expression_Array(array(), $token->getLine());
     }
     $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
     return new \GL\Core\Twig\TwigRouteNode($expr, $options, $token->getLine(), $this->getTag());
 }
 /**
  * Parses a token and returns a node.
  *
  * @param \Twig_Token $token A \Twig_Token instance
  *
  * @return \Twig_NodeInterface A \Twig_NodeInterface instance
  */
 public function parse(\Twig_Token $token)
 {
     $expr = $this->parser->getExpressionParser()->parseExpression();
     // attributes
     if ($this->parser->getStream()->test(\Twig_Token::NAME_TYPE, 'with')) {
         $this->parser->getStream()->next();
         $attributes = $this->parser->getExpressionParser()->parseExpression();
     } else {
         $attributes = new \Twig_Node_Expression_Array(array(), $token->getLine());
     }
     $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
     return new JavascriptNode($expr, $attributes, $token->getLine(), $this->getTag());
 }
예제 #22
0
 /**
  * Parses a token and returns a node.
  *
  * @param Twig_Token $token A Twig_Token instance
  *
  * @return Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(Twig_Token $token)
 {
     $stream = $this->parser->getStream();
     $parent = $this->parser->getExpressionParser()->parseExpression();
     list($variables, $only, $ignoreMissing) = $this->parseArguments();
     // inject a fake parent to make the parent() function work
     $stream->injectTokens(array(new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', $token->getLine()), new Twig_Token(Twig_Token::NAME_TYPE, 'extends', $token->getLine()), new Twig_Token(Twig_Token::STRING_TYPE, '__parent__', $token->getLine()), new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', $token->getLine())));
     $module = $this->parser->parse($stream, array($this, 'decideBlockEnd'), true);
     // override the parent with the correct one
     $module->setNode('parent', $parent);
     $this->parser->embedTemplate($module);
     $stream->expect(Twig_Token::BLOCK_END_TYPE);
     return new Twig_Node_Embed($module->getAttribute('filename'), $module->getAttribute('index'), $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
 }
예제 #23
0
 public function parse(Token $token)
 {
     $expr = $this->parser->getExpressionParser()->parseExpression();
     // attributes
     if ($this->parser->getStream()->test(Token::NAME_TYPE, 'with')) {
         $this->parser->getStream()->next();
         $attributes = $this->parser->getExpressionParser()->parseExpression();
     } else {
         $attributes = new ExpressionArray(array(), $token->getLine());
     }
     $options = new ExpressionArray(array(), $token->getLine());
     $this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
     return new RenderNode(array('expr' => $expr, 'attributes' => $attributes, 'options' => $options), array(), $token->getLine(), $this->getTag());
 }
 /**
  * {@inheritdoc}
  */
 public function parse(\Twig_Token $token)
 {
     $media = $this->parser->getExpressionParser()->parseExpression();
     $this->parser->getStream()->next();
     $format = $this->parser->getExpressionParser()->parseExpression();
     // attributes
     if ($this->parser->getStream()->test(\Twig_Token::NAME_TYPE, 'with')) {
         $this->parser->getStream()->next();
         $attributes = $this->parser->getExpressionParser()->parseExpression();
     } else {
         $attributes = new \Twig_Node_Expression_Array(array(), $token->getLine());
     }
     $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
     return new ThumbnailNode($this->extensionName, $media, $format, $attributes, $token->getLine(), $this->getTag());
 }
예제 #25
0
 /**
  * @param \Twig_Token $token Token consumed by the lexer.
  *
  * @return \Twig_Node
  * @throws \Twig_Error_Syntax
  */
 public function parse(\Twig_Token $token)
 {
     $stream = $this->parser->getStream();
     if ($stream->getCurrent()->getType() != \Twig_Token::BLOCK_END_TYPE) {
         $error = sprintf("'%s' does not require any arguments.", $this->getTag());
         throw new \Twig_Error_Syntax($error, $token->getLine(), $this->parser->getFilename());
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     if (FormState::$current === null) {
         throw new \Twig_Error_Syntax('Trying to close a form tag, while none opened', $token->getLine(), $this->parser->getFilename());
     } else {
         FormState::$current = null;
     }
     return new FormEndNode($token->getLine(), $this->getTag());
 }
 /**
  * {@inheritdoc}
  */
 public function parse(\Twig_Token $token)
 {
     if ($this->parser->getStream()->test(\Twig_Token::STRING_TYPE)) {
         $message = $this->parser->getExpressionParser()->parseExpression();
     } else {
         $message = new \Twig_Node_Expression_Constant('Template information', $token->getLine());
     }
     if ($this->parser->getStream()->test(\Twig_Token::STRING_TYPE)) {
         $translationBundle = $this->parser->getExpressionParser()->parseExpression();
     } else {
         $translationBundle = null;
     }
     $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
     return new TemplateBoxNode($message, $translationBundle, $this->enabled, $this->translator, $token->getLine(), $this->getTag());
 }
 public function parse(\Twig_Token $token)
 {
     $lineno = $token->getLine();
     $stream = $this->parser->getStream();
     // {% stopwatch 'bar' %}
     $name = $this->parser->getExpressionParser()->parseExpression();
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     // {% endstopwatch %}
     $body = $this->parser->subparse([$this, 'decideStopwatchEnd'], true);
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     if ($this->debugbarAvailable) {
         return new StopwatchNode($name, $body, new \Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $lineno, $this->getTag());
     }
     return $body;
 }
예제 #28
0
 /**
  * Parses a token and returns a node.
  *
  * @param Twig_Token $token A Twig_Token instance
  *
  * @return Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(Twig_Token $token)
 {
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag());
 }
예제 #29
0
 /**
  * Parses a token and returns a node.
  *
  * @param \Twig_Token $token A Twig_Token instance
  *
  * @return \Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(\Twig_Token $token)
 {
     $expr = $this->parser->getExpressionParser()->parseExpression();
     $stream = $this->parser->getStream();
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return new \phpbb\template\twig\node\includejs($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag());
 }
예제 #30
0
 /**
  * {@inheritdoc}
  *
  * @param  \Twig_Token         $token
  * @return \Twig_NodeInterface
  */
 public function parse(\Twig_Token $token)
 {
     $methodName = $this->parser->getStream()->expect(\Twig_Token::NAME_TYPE)->getValue();
     $arguments = $this->parser->getExpressionParser()->parseArguments();
     $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
     return new Node(array('arguments' => $arguments), array('methodName' => $methodName), $token->getLine(), $this->getTag());
 }