I would like to escape a file, which I'm including
following code won't escape the html tags in file "_custom_plugin_script.html.twig". Is there another way?
<pre> {% autoescape true %} {% include "_custom_plugin_script.html.twig" | raw %} {% endautoescape %} </pre> After a couple days, I have found a workaround, but not an answer. So first raw would not escape therefore I should use escape. However raw and escape won't work within {% %} but in {{}}.
So here comes the workaround
Content of the Action
$customPluginScript = $app['twig']->render('_custom_plugin_script.html.twig', array( 'data' => $data, )); return $app['twig']->render('confirm.html.twig', array( 'data' => $data, 'customPluginScript' => $customPluginScript )); And the a part of confirm.html.twig
<script> // don't escape content of customPluginScript {{ customPluginScript | raw }} </script> <!-- escape content of customPluginScript --> <pre> {{ customPluginScript }} </pre>
{{ var|raw }}was what I was looking for when I found this question via Google.