symfony2 twig whitelist html tags

后端 未结 5 2443
盖世英雄少女心
盖世英雄少女心 2021-02-20 08:23

I pass a variable to my twig template in Symfony2, this variable may contain
html tags, I have tried to create an extension (function), but the variabl

5条回答
  •  感情败类
    2021-02-20 08:56

    Actually, you can use native PHP function strip_tags by following:

    {{ var|striptags('
    ')|raw }}

    you can allow multiple tags with following code:

    {{ var|striptags('

    ')|raw }}

提交回复
热议问题