Commit 726f41bf authored by webchick's avatar webchick

Issue #2221535 by Cottser, joelpittet: TwigNodeVisitor's priority is too early...

Issue #2221535 by Cottser, joelpittet: TwigNodeVisitor's priority is too early and breaks some filters and macros.
parent e617d17b
......@@ -47,10 +47,9 @@ function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
}
/**
* Implements Twig_NodeVisitorInterface::getPriority().
* {@inheritdoc}
*/
function getPriority() {
// We want to run before other NodeVisitors like Escape or Optimizer
return -1;
return 1;
}
}
<?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>');
}
}
{# Template for testing |raw with autoescape. #}
{% autoescape %}
{{ script|raw }}
{% endautoescape %}
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment