]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/twig/twig/lib/Twig/TokenParser/Import.php
e7050c70c6e81d1a70ea1d32d1e1be2d18e6153c
4 * This file is part of Twig.
6 * (c) 2009 Fabien Potencier
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
16 * {% import 'forms.html' as forms %}
19 class Twig_TokenParser_Import
extends Twig_TokenParser
22 * Parses a token and returns a node.
24 * @param Twig_Token $token A Twig_Token instance
26 * @return Twig_NodeInterface A Twig_NodeInterface instance
28 public function parse(Twig_Token
$token)
30 $macro = $this->parser
->getExpressionParser()->parseExpression();
31 $this->parser
->getStream()->expect('as');
32 $var = new Twig_Node_Expression_AssignName($this->parser
->getStream()->expect(Twig_Token
::NAME_TYPE
)->getValue(), $token->getLine());
33 $this->parser
->getStream()->expect(Twig_Token
::BLOCK_END_TYPE
);
35 $this->parser
->addImportedSymbol('template', $var->getAttribute('name'));
37 return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag());
41 * Gets the tag name associated with this token parser.
43 * @return string The tag name
45 public function getTag()