I would like to use variables containing HTML inside a trans
tag in my Twig template. (The variables contain the start and the end of a link which appears at different positions in the sentence for different languages.)
There is some documentation about "Drupal 8 Twig Templates and Translations" which explains that for variables inside the trans
tag there is a |placeholder
-filter and a |raw
-filter (for older versions: |passthrough
).
I see no difference in the output using these filters.
Here is my template:
{% set string = '<strong>&</strong>' %}
<div>
{% trans %}
Escaped: {{ string }}
{% endtrans %}
</div>
<div>
{% trans %}
Pass-through: {{ string|raw }}
{% endtrans %}
</div>
<div>
{% trans %}
Placeholder: {{ string|placeholder }}
{% endtrans %}
</div>
And here ist the output:
Escaped: <strong>&</strong>
Pass-through: <strong>&</strong>
Placeholder: <strong>&</strong>
Is there any filter that will switch off escaping?