Open
Description
#102 introduce the is_safe_callback
option instead of the old is_safe => ['html']
that was causing some issues and unexpected behavior (changing the way Symfony does the escaping by default).
But there is an issue with this method as Twig use this method during the compile phase. So the generated templates never call the callback again.
So on a fresh and empty cache:
- if my first request has Edit In Place disabled, the template contains:
echo twig_escape_filter($this->env, $this->extensions['Translation\Bundle\Twig\EditInPlaceExtension']->trans("navigation.dropdown.rent.title"), "html", null, true);
- if my first request has Edit In Place enabled, the template contains:
echo $this->extensions['Translation\Bundle\Twig\EditInPlaceExtension']->trans("navigation.dropdown.rent.title");
Enabling and disabling the Edit In Place (via the Activator service) does not re-compile Twig cache.
There is two issues:
- you can compile the second one on a production server, and the only way to get escaping again would be to clear the cache;
- the Edit In Place feature can't work out of the box if the templates are compiled already.
Some possible solutions:
- move the escaping inside the Twig Extension and mark it as always safe (easy);
- build a new node visitor and change the way the cache is build (hard).