twig striptags and html special chars

前端 未结 5 1586
小蘑菇
小蘑菇 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:37

    Arf, I finally found it :

    I am using a custom twig filter that just applies a php function:

    {{ organization.shortDescription ?: php('html_entity_decode',organization.content|striptags|truncate(200, '...')) }}
    

    Now it renders correctly

    My php extension:

提交回复
热议问题