Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escape special characters in twig

Tags:

php

twig

symfony

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?

like image 680
Gabriel Muñumel Avatar asked Jan 30 '15 10:01

Gabriel Muñumel


1 Answers

You can do this:

{{ '↑' | escape }}

e is also used as an alias of escape, meaning

{{ '↑' | e }}

will also work.

Twig documentation on 'escape'.

like image 90
Albzi Avatar answered Nov 10 '22 08:11

Albzi