diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigRawTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigRawTest.php new file mode 100644 index 0000000..e93585c --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigRawTest.php @@ -0,0 +1,45 @@ + 'Twig raw filter', + 'description' => "Tests Twig 'raw' filter.", + 'group' => 'Theme', + ); + } + + /** + * Tests the raw filter inside an autoescape tag. + */ + public function testAutoescapeRaw() { + $test = array( + '#theme' => 'twig_raw_test', + '#script' => '', + ); + $rendered = drupal_render($test); + $this->drupalSetContent($rendered); + $this->assertRaw(''); + } + +} diff --git a/core/modules/system/tests/modules/twig_theme_test/templates/twig-raw-test.html.twig b/core/modules/system/tests/modules/twig_theme_test/templates/twig-raw-test.html.twig new file mode 100644 index 0000000..2053250 --- /dev/null +++ b/core/modules/system/tests/modules/twig_theme_test/templates/twig-raw-test.html.twig @@ -0,0 +1,4 @@ +{# Template for testing |raw with autoescape. #} +{% autoescape %} + {{ script|raw }} +{% endautoescape %} diff --git a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module index e47b30c..5a9f095 100644 --- a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module +++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module @@ -19,6 +19,10 @@ function twig_theme_test_theme($existing, $type, $theme, $path) { 'variables' => array(), 'template' => 'twig_namespace_test', ); + $items['twig_raw_test'] = array( + 'variables' => array('script' => ''), + 'template' => 'twig-raw-test', + ); return $items; }