Twig: How to print special symbols, such as Copyright, Trademark, etc

前端 未结 2 1375
一个人的身影
一个人的身影 2021-01-24 07:50

I want to use special symbols, but instead all I get printed question mark symbol �

I tried

{% autoescape \'html\' %}
    {{ \'©\'|escape(\'html\') }}           


        
2条回答
  •  执念已碎
    2021-01-24 08:23

    Use raw filter :

    {{ '©'|raw }}
    

    http://twig.sensiolabs.org/doc/filters/raw.html

    If the output is supposed to be HTML, you can also use HTML entity notation, for example trademark sign:

    {{ '™' }}
    

    or email sign:

    {{ '@' }}
    

提交回复
热议问题