Drupal - Possible to turn off Twig debug mode for a specific template?

There is also this alternative found here and here where you can do something like this using the triple filter |render|striptags|trim :

<img src="{{ url_image }}" alt="{{ title|render|striptags|trim }}" />

It worked perfectly in my case (|escape didn't work)


For my use case, which was a to add a background image to a div, I needed to add spaceless, escape, and striptags as depicted here:

<div class="videoPoster js-videoPoster" style="background-image:url('{% spaceless %}{{ img_url|escape|striptags('<!-- -->') }}{% endspaceless %}');">Hello World</div>

Tags:

Theming

8