public function TwigEnvironment::compileSource in Drupal 9
File
- core/lib/Drupal/Core/Template/TwigEnvironment.php, line 108
Class
- TwigEnvironment
- A class that defines a Twig environment for Drupal.
Namespace
Drupal\Core\Template
Code
public function compileSource(Source $source) {
$frontMatter = FrontMatter::create($source
->getCode(), Yaml::class);
try {
if (($line = $frontMatter
->getLine()) > 1) {
$content = "{% line {$line} %}" . $frontMatter
->getContent();
$source = new Source($content, $source
->getName(), $source
->getPath());
}
} catch (FrontMatterParseException $exception) {
$message = sprintf($exception
->getMessage() . ' in %s', $source
->getPath() ?: $source
->getName());
throw new SyntaxError($message, $exception
->getSourceLine(), $source, $exception);
}
return parent::compileSource($source);
}