knapsack-cloud/twig-renderer

Fix autoescaping for Twig 2.x

andriokha opened this issue · 0 comments

Thanks for a very useful project!

Currently there's a boolean configuration option called autoescape that gets passed directly to \Twig\Environment::__construct() in

$twig = new \Twig_Environment($loaders, [
'debug' => $this->config['debug'],
'autoescape' => $this->config['autoescape'],

In Twig 1:

  • true is the same as html and uses that escaping strategy
  • false disables auto-escaping

In Twig 2 true was removed as an option (so to get the old true behaviour you should pass html).

It occurred to me that we could expose the full range of options, but I'm not sure if there's really any demand for that.