createTwigTemplate example

return $file;
  }

  /** * Tests broken front matter. * * @covers \Drupal\Core\Template\TwigEnvironment::getTemplateMetadata * @covers \Drupal\Component\FrontMatter\Exception\FrontMatterParseException */
  public function testFrontMatterBroken() {
    $source = "---\ncollection:\n- key: foo\n foo: bar\n---\n" . ComponentFrontMatterTest::SOURCE;
    $file = $this->createTwigTemplate($source);
    $this->expectException(SyntaxError::class);
    $this->expectExceptionMessage('An error occurred when attempting to parse front matter data on line 4 in ' . $file);
    $this->twig->getTemplateMetadata(basename($file));
  }

  /** * Test Twig template front matter. * * @param array|null $yaml * The YAML used for metadata in a Twig template. * @param int $line * The expected line number where the source code starts. * @param string $content * The content to use for testing purposes. * * @covers \Drupal\Core\Template\TwigEnvironment::compileSource * @covers \Drupal\Core\Template\TwigEnvironment::getTemplateMetadata * * @dataProvider \Drupal\Tests\Component\FrontMatter\FrontMatterTest::providerFrontMatterData */
Home | Imprint | This part of the site doesn't use cookies.