B
B
BonBon Slick2018-07-23 16:47:59
Twig
BonBon Slick, 2018-07-23 16:47:59

Filtering (escape vs raw) Twig variable output?

Record difference

{{ 'title.homepage' | trans }}
{{ 'title.homepage' | trans | raw }}
{% trans %} title.homepage {% endtrans %}

{% autoescape %}
     {{ var | trans| raw }}  
{% endautoescape %}

{% autoescape %}
    {{ var | trans }}  
{% endautoescape %}

 {% set strategy = 'html' %}
{% autoescape 'html' %}
     {{ var | trans |escape(strategy)|raw }}
 {% endautoescape %}


 {% set strategy = 'html' %}
{% autoescape 'html' %}
    {{ var | trans |escape(strategy) }}
{% endautoescape %}

Even with strategies, ugh bells and whistles.
I'm a bit confused what, when and why is it preferable to use?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question