You are here

protected function FrontMatterTest::createTwigTemplate in Drupal 10

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Theme/FrontMatterTest.php \Drupal\KernelTests\Core\Theme\FrontMatterTest::createTwigTemplate()

Creates a new temporary Twig file.

Parameters

string $content: The contents of the Twig file to save.

Return value

string The absolute path to the temporary file.

File

core/tests/Drupal/KernelTests/Core/Theme/FrontMatterTest.php, line 63

Class

FrontMatterTest
Tests Twig front matter support.

Namespace

Drupal\KernelTests\Core\Theme

Code

protected function createTwigTemplate(string $content = '') : string {
  $file = tempnam(sys_get_temp_dir(), 'twig') . ".html.twig";
  file_put_contents($file, $content);
  return $file;
}