Gabriel Muñumel
Gabriel Muñumel

Reputation: 1876

Escape special characters in twig

I'm trying to espace these characters in twig: ↑, ↓, \/ and /\.

I tried:

{{ '↑' }}

and

{% raw %}
   ↑
{% endraw %}

But symfony always complaint about &, \, # characters.

I also tried the following with not success: How to escape Twig delimiters in a Twig template?

Upvotes: 6

Views: 19688

Answers (1)

Albzi
Albzi

Reputation: 15609

You can do this:

{{ '↑' | escape }}

e is also used as an alias of escape, meaning

{{ '↑' | e }}

will also work.

Twig documentation on 'escape'.

Upvotes: 12

Related Questions