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

Includes a template. More...

+ Inheritance diagram for Twig_TokenParser_Include:
+ Collaboration diagram for Twig_TokenParser_Include:

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...
 

Protected Member Functions

 parseArguments ()
 

Additional Inherited Members

- Protected Attributes inherited from Twig_TokenParser
 $parser
 

Detailed Description

Includes a template.

  {% include 'header.html' %}
    Body
  {% include 'footer.html' %}

Definition at line 22 of file Include.php.

Member Function Documentation

◆ getTag()

Twig_TokenParser_Include::getTag ( )

Gets the tag name associated with this token parser.

Returns
string The tag name

Implements Twig_TokenParserInterface.

Definition at line 59 of file Include.php.

Referenced by parse().

60  {
61  return 'include';
62  }
+ Here is the caller graph for this function:

◆ parse()

Twig_TokenParser_Include::parse ( Twig_Token  $token)

Parses a token and returns a node.

Returns
Twig_NodeInterface
Exceptions
Twig_Error_Syntax

Implements Twig_TokenParserInterface.

Definition at line 24 of file Include.php.

References Twig_Token\getLine(), getTag(), and parseArguments().

25  {
26  $expr = $this->parser->getExpressionParser()->parseExpression();
27 
28  list($variables, $only, $ignoreMissing) = $this->parseArguments();
29 
30  return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
31  }
Represents an include node.
Definition: Include.php:18
getTag()
Gets the tag name associated with this token parser.
Definition: Include.php:59
getLine()
Definition: Token.php:87
+ Here is the call graph for this function:

◆ parseArguments()

Twig_TokenParser_Include::parseArguments ( )
protected

Definition at line 33 of file Include.php.

References GuzzleHttp\Psr7\$stream, Twig_Token\BLOCK_END_TYPE, and Twig_Token\NAME_TYPE.

Referenced by Twig_TokenParser_Embed\parse(), and parse().

34  {
35  $stream = $this->parser->getStream();
36 
37  $ignoreMissing = false;
38  if ($stream->nextIf(Twig_Token::NAME_TYPE, 'ignore')) {
39  $stream->expect(Twig_Token::NAME_TYPE, 'missing');
40 
41  $ignoreMissing = true;
42  }
43 
44  $variables = null;
45  if ($stream->nextIf(Twig_Token::NAME_TYPE, 'with')) {
46  $variables = $this->parser->getExpressionParser()->parseExpression();
47  }
48 
49  $only = false;
50  if ($stream->nextIf(Twig_Token::NAME_TYPE, 'only')) {
51  $only = true;
52  }
53 
55 
56  return array($variables, $only, $ignoreMissing);
57  }
$stream
PHP stream implementation.
const NAME_TYPE
Definition: Token.php:32
const BLOCK_END_TYPE
Definition: Token.php:30
+ Here is the caller graph for this function:

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