PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.0-dev2
Elementor Website Builder – more than just a page builder v3.28.0-dev2
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 4.0.7 All 451 releases
elementor / vendor_prefixed / twig / src / Node / Expression / BlockReferenceExpression.php

BlockReferenceExpression.php in Elementor Website Builder – more than just a page builder 3.28.0-dev2, at vendor_prefixed/twig/src/Node/Expression/BlockReferenceExpression.php

64 lines 2.1 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\Node\Expression;
13
14 use ElementorDeps\Twig\Compiler;
15 use ElementorDeps\Twig\Node\Node;
16 /**
17 * Represents a block call node.
18 *
19 * @author Fabien Potencier <fabien@symfony.com>
20 */
21 class BlockReferenceExpression extends AbstractExpression
22 {
23 public function __construct(Node $name, ?Node $template, int $lineno, ?string $tag = null)
24 {
25 $nodes = ['name' => $name];
26 if (null !== $template) {
27 $nodes['template'] = $template;
28 }
29 parent::__construct($nodes, ['is_defined_test' => \false, 'output' => \false], $lineno, $tag);
30 }
31 public function compile(Compiler $compiler) : void
32 {
33 if ($this->getAttribute('is_defined_test')) {
34 $this->compileTemplateCall($compiler, 'hasBlock');
35 } else {
36 if ($this->getAttribute('output')) {
37 $compiler->addDebugInfo($this);
38 $compiler->write('yield from ');
39 $this->compileTemplateCall($compiler, 'yieldBlock')->raw(";\n");
40 } else {
41 $this->compileTemplateCall($compiler, 'renderBlock');
42 }
43 }
44 }
45 private function compileTemplateCall(Compiler $compiler, string $method) : Compiler
46 {
47 if (!$this->hasNode('template')) {
48 $compiler->write('$this');
49 } else {
50 $compiler->write('$this->loadTemplate(')->subcompile($this->getNode('template'))->raw(', ')->repr($this->getTemplateName())->raw(', ')->repr($this->getTemplateLine())->raw(')');
51 }
52 $compiler->raw(\sprintf('->unwrap()->%s', $method));
53 return $this->compileBlockArguments($compiler);
54 }
55 private function compileBlockArguments(Compiler $compiler) : Compiler
56 {
57 $compiler->raw('(')->subcompile($this->getNode('name'))->raw(', $context');
58 if (!$this->hasNode('template')) {
59 $compiler->raw(', $blocks');
60 }
61 return $compiler->raw(')');
62 }
63 }
64