'{{ foo }} {{ foo }}', 'js' => '{{ bar }} {{ bar }}', )); $twig = new Twig_Environment($loader, array( 'debug' => true, 'cache' => false, 'autoescape' => array($this, 'escapingStrategyCallback'), )); $this->assertEquals('foo<br/ > foo<br/ >', $twig->render('html', array('foo' => 'foo
'))); $this->assertEquals('foo\x3Cbr\x2F\x20\x3E foo\x3Cbr\x2F\x20\x3E', $twig->render('js', array('bar' => 'foo
'))); } public function escapingStrategyCallback($filename) { return $filename; } }