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

前端 未结 2 1363
一个人的身影
一个人的身影 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:

    {{ '@' }}
    
    0 讨论(0)
  • 2021-01-24 08:24

    Since you want to display a static string and not a variable, you can write the character directly, you don't need to use the {{ }} tag:

    ©
    

    Or by using the HTML entity cited by Miro:

    ™
    
    0 讨论(0)
提交回复
热议问题