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

Breadcrumb

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

function Template::render

Same name in this branch
  1. 11.1.x vendor/phpunit/php-text-template/src/Template.php \SebastianBergmann\Template\Template::render()

File

vendor/twig/twig/src/Template.php, line 348

Class

Template
Default base class for compiled templates.

Namespace

Twig

Code

public function render(array $context) : string {
    if (!$this->useYield) {
        $level = ob_get_level();
        if ($this->env
            ->isDebug()) {
            ob_start();
        }
        else {
            ob_start(function () {
                return '';
            });
        }
        try {
            $this->display($context);
        } catch (\Throwable $e) {
            while (ob_get_level() > $level) {
                ob_end_clean();
            }
            throw $e;
        }
        return ob_get_clean();
    }
    $content = '';
    foreach ($this->yield($context) as $data) {
        $content .= $data;
    }
    return $content;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal