twig striptags and html special chars

前端 未结 5 1628
小蘑菇
小蘑菇 2021-01-04 00:23

I am using twig to render a view and I am using the striptags filter to remove html tags. However, html special chars are now rendered as text as the whole element is surrou

5条回答
  •  我在风中等你
    2021-01-04 00:50

    I was trying some of, among others, these answers:

    {{ organization.content|striptags|truncate(200, true) }}
    {{ organization.content|raw|striptags|truncate(200, true) }}
    {{ organization.content|striptags|raw|truncate(200, true) }}
    etc.
    

    And still got strange characters in the final form. What helped me, is putting the raw filter on the end of all operations, i.e:

    {{ organization.content|striptags|truncate(200, '...')|raw }}
    

提交回复
热议问题