Issue #2221535 by Cottser, joelpittet: TwigNodeVisitor's priority is too early and breaks some filters and macros.

8.0.x
webchick 2014-03-20 14:13:45 -07:00
parent e617d17b02
commit 726f41bf4c
4 changed files with 55 additions and 3 deletions

View File

@ -47,10 +47,9 @@ class TwigNodeVisitor implements \Twig_NodeVisitorInterface {
}
/**
* Implements Twig_NodeVisitorInterface::getPriority().
* {@inheritdoc}
*/
function getPriority() {
// We want to run before other NodeVisitors like Escape or Optimizer
return -1;
return 1;
}
}

View File

@ -0,0 +1,45 @@
<?php
/**
* @file
* Contains \Drupal\system\Tests\Theme\TwigRawTest.
*/
namespace Drupal\system\Tests\Theme;
use Drupal\simpletest\WebTestBase;
/**
* Tests 'raw' Twig filter.
*/
class TwigRawTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('twig_theme_test');
public static function getInfo() {
return array(
'name' => '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' => '<script>alert("This alert is real because I will put it through the raw filter!");</script>',
);
$rendered = drupal_render($test);
$this->drupalSetContent($rendered);
$this->assertRaw('<script>alert("This alert is real because I will put it through the raw filter!");</script>');
}
}

View File

@ -0,0 +1,4 @@
{# Template for testing |raw with autoescape. #}
{% autoescape %}
{{ script|raw }}
{% endautoescape %}

View File

@ -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;
}