]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/twig/twig/lib/Twig/TokenParser/From.php
4 * This file is part of Twig.
6 * (c) 2010 Fabien Potencier
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
16 * {% from 'forms.html' import forms %}
19 class Twig_TokenParser_From
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 $stream = $this->parser
->getStream();
32 $stream->expect('import');
36 $name = $stream->expect(Twig_Token
::NAME_TYPE
)->getValue();
39 if ($stream->test('as')) {
42 $alias = $stream->expect(Twig_Token
::NAME_TYPE
)->getValue();
45 $targets[$name] = $alias;
47 if (!$stream->test(Twig_Token
::PUNCTUATION_TYPE
, ',')) {
54 $stream->expect(Twig_Token
::BLOCK_END_TYPE
);
56 $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser
->getVarName(), $token->getLine()), $token->getLine(), $this->getTag());
58 foreach ($targets as $name => $alias) {
59 $this->parser
->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var'));
66 * Gets the tag name associated with this token parser.
68 * @return string The tag name
70 public function getTag()