Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ModuleNode.php

function ModuleNode::compileDisplay

1 call to ModuleNode::compileDisplay()
ModuleNode::compileTemplate in vendor/twig/twig/src/Node/ModuleNode.php

File

vendor/twig/twig/src/Node/ModuleNode.php, line 322

Class

ModuleNode
Represents a module node.

Namespace

Twig\Node

Code

protected function compileDisplay(Compiler $compiler) {
    $compiler->write("protected function doDisplay(array \$context, array \$blocks = []): iterable\n", "{\n")
        ->indent()
        ->write("\$macros = \$this->macros;\n")
        ->subcompile($this->getNode('display_start'))
        ->subcompile($this->getNode('body'));
    if ($this->hasNode('parent')) {
        $parent = $this->getNode('parent');
        $compiler->addDebugInfo($parent);
        if ($parent instanceof ConstantExpression) {
            $compiler->write('$this->parent = $this->loadTemplate(')
                ->subcompile($parent)
                ->raw(', ')
                ->repr($this->getSourceContext()
                ->getName())
                ->raw(', ')
                ->repr($parent->getTemplateLine())
                ->raw(");\n");
        }
        $compiler->write('yield from ');
        if ($parent instanceof ConstantExpression) {
            $compiler->raw('$this->parent');
        }
        else {
            $compiler->raw('$this->getParent($context)');
        }
        $compiler->raw("->unwrap()->yield(\$context, array_merge(\$this->blocks, \$blocks));\n");
    }
    $compiler->subcompile($this->getNode('display_end'));
    if (!$this->hasNode('parent')) {
        $compiler->write("yield from [];\n");
    }
    $compiler->outdent()
        ->write("}\n\n");
}
RSS feed
Powered by Drupal