striptags

The striptags filter strips SGML/XML tags and replace adjacent whitespace by one space:

striptags フィルターは、SGML/XML タグを取り除き、隣接する空白を 1 つのスペースに置き換えます。
1
{{ some_html|striptags }}

You can also provide tags which should not be stripped:

削除してはならないタグ​​を指定することもできます:
1
{{ some_html|striptags('<br><p>') }}

In this example, the <br/>, <br>, <p>, and </p> tags won't be removed from the string.

この例では、、、、およびタグは文字列から削除されません。

Note

ノート

Internally, Twig uses the PHP strip_tags function.

内部的に、Twig は PHP の strip_tags 関数を使用します。

Arguments

  • allowable_tags: Tags which should not be stripped
    allowable_tags: 剥がしてはいけないタグ