PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.0-dev1
Elementor Website Builder – more than just a page builder v3.28.0-dev1
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / vendor_prefixed / twig / src / TokenParser / IncludeTokenParser.php

IncludeTokenParser.php in Elementor Website Builder – more than just a page builder 3.28.0-dev1, at vendor_prefixed/twig/src/TokenParser/IncludeTokenParser.php

77 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 * (c) Armin Ronacher
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12 namespace ElementorDeps\Twig\TokenParser;
13
14 use ElementorDeps\Twig\Node\IncludeNode;
15 use ElementorDeps\Twig\Node\Node;
16 use ElementorDeps\Twig\Token;
17 /**
18 * Includes a template.
19 *
20 * {% include 'header.html' %}
21 * Body
22 * {% include 'footer.html' %}
23 *
24 * @internal
25 */
26 class IncludeTokenParser extends AbstractTokenParser
27 {
28 public function parse(Token $token) : Node
29 {
30 $expr = $this->parser->getExpressionParser()->parseExpression();
31 [$variables, $only, $ignoreMissing] = $this->parseArguments();
32 return new IncludeNode($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
33 }
34 protected function parseArguments()
35 {
36 $stream = $this->parser->getStream();
37 $ignoreMissing = \false;
38 if ($stream->nextIf(
39 /* Token::NAME_TYPE */
40 5,
41 'ignore'
42 )) {
43 $stream->expect(
44 /* Token::NAME_TYPE */
45 5,
46 'missing'
47 );
48 $ignoreMissing = \true;
49 }
50 $variables = null;
51 if ($stream->nextIf(
52 /* Token::NAME_TYPE */
53 5,
54 'with'
55 )) {
56 $variables = $this->parser->getExpressionParser()->parseExpression();
57 }
58 $only = \false;
59 if ($stream->nextIf(
60 /* Token::NAME_TYPE */
61 5,
62 'only'
63 )) {
64 $only = \true;
65 }
66 $stream->expect(
67 /* Token::BLOCK_END_TYPE */
68 3
69 );
70 return [$variables, $only, $ignoreMissing];
71 }
72 public function getTag() : string
73 {
74 return 'include';
75 }
76 }
77