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

Breadcrumb

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

function Environment::compileSource

Compiles a template source code.

Throws

SyntaxError When there was an error during tokenizing, parsing or compiling

3 calls to Environment::compileSource()
Environment::loadTemplate in vendor/twig/twig/src/Environment.php
Loads a template internal representation.
TwigEnvironment::compileSource in core/lib/Drupal/Core/Template/TwigEnvironment.php
Compiles a template source code.
TwigEnvironment::compileSource in core/lib/Drupal/Core/Template/TwigEnvironment.php
Compiles a template source code.
1 method overrides Environment::compileSource()
TwigEnvironment::compileSource in core/lib/Drupal/Core/Template/TwigEnvironment.php
Compiles a template source code.

File

vendor/twig/twig/src/Environment.php, line 564

Class

Environment
Stores the Twig configuration and renders templates.

Namespace

Twig

Code

public function compileSource(Source $source) : string {
    try {
        return $this->compile($this->parse($this->tokenize($source)));
    } catch (Error $e) {
        $e->setSourceContext($source);
        throw $e;
    } catch (\Exception $e) {
        throw new SyntaxError(\sprintf('An exception has been thrown during the compilation of a template ("%s").', $e->getMessage()), -1, $source, $e);
    }
}
RSS feed
Powered by Drupal