]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/twig/twig/lib/Twig/TokenParser/Include.php
4 * This file is part of Twig.
6 * (c) 2009 Fabien Potencier
7 * (c) 2009 Armin Ronacher
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
14 * Includes a template.
17 * {% include 'header.html' %}
19 * {% include 'footer.html' %}
22 class Twig_TokenParser_Include
extends Twig_TokenParser
25 * Parses a token and returns a node.
27 * @param Twig_Token $token A Twig_Token instance
29 * @return Twig_NodeInterface A Twig_NodeInterface instance
31 public function parse(Twig_Token
$token)
33 $expr = $this->parser
->getExpressionParser()->parseExpression();
35 list($variables, $only, $ignoreMissing) = $this->parseArguments();
37 return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
40 protected function parseArguments()
42 $stream = $this->parser
->getStream();
44 $ignoreMissing = false;
45 if ($stream->test(Twig_Token
::NAME_TYPE
, 'ignore')) {
47 $stream->expect(Twig_Token
::NAME_TYPE
, 'missing');
49 $ignoreMissing = true;
53 if ($stream->test(Twig_Token
::NAME_TYPE
, 'with')) {
56 $variables = $this->parser
->getExpressionParser()->parseExpression();
60 if ($stream->test(Twig_Token
::NAME_TYPE
, 'only')) {
66 $stream->expect(Twig_Token
::BLOCK_END_TYPE
);
68 return array($variables, $only, $ignoreMissing);
72 * Gets the tag name associated with this token parser.
74 * @return string The tag name
76 public function getTag()