ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_TokenParser_Import Class Reference

Imports macros. More...

+ Inheritance diagram for Twig_TokenParser_Import:
+ Collaboration diagram for Twig_TokenParser_Import:

Public Member Functions

 parse (Twig_Token $token)
 Parses a token and returns a node. More...
 
 getTag ()
 Gets the tag name associated with this token parser. More...
 
- Public Member Functions inherited from Twig_TokenParser
 setParser (Twig_Parser $parser)
 Sets the parser associated with this token parser. More...
 

Additional Inherited Members

- Protected Attributes inherited from Twig_TokenParser
 $parser
 

Detailed Description

Imports macros.

  {% import 'forms.html' as forms %}

Definition at line 21 of file Import.php.

Member Function Documentation

◆ getTag()

Twig_TokenParser_Import::getTag ( )

Gets the tag name associated with this token parser.

Returns
string The tag name

Implements Twig_TokenParserInterface.

Definition at line 35 of file Import.php.

Referenced by parse().

36  {
37  return 'import';
38  }
+ Here is the caller graph for this function:

◆ parse()

Twig_TokenParser_Import::parse ( Twig_Token  $token)

Parses a token and returns a node.

Returns
Twig_NodeInterface
Exceptions
Twig_Error_Syntax

Implements Twig_TokenParserInterface.

Definition at line 23 of file Import.php.

References Twig_Token\BLOCK_END_TYPE, Twig_Token\getLine(), getTag(), and Twig_Token\NAME_TYPE.

24  {
25  $macro = $this->parser->getExpressionParser()->parseExpression();
26  $this->parser->getStream()->expect('as');
27  $var = new Twig_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(), $token->getLine());
28  $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
29 
30  $this->parser->addImportedSymbol('template', $var->getAttribute('name'));
31 
32  return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag());
33  }
Represents an import node.
Definition: Import.php:17
getTag()
Gets the tag name associated with this token parser.
Definition: Import.php:35
getLine()
Definition: Token.php:87
const NAME_TYPE
Definition: Token.php:32
const BLOCK_END_TYPE
Definition: Token.php:30
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: