Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 1 | ``striptags`` |
| 2 | ============= |
| 3 | |
| 4 | The ``striptags`` filter strips SGML/XML tags and replace adjacent whitespace |
| 5 | by one space: |
| 6 | |
| 7 | .. code-block:: twig |
| 8 | |
| 9 | {{ some_html|striptags }} |
| 10 | |
| 11 | You can also provide tags which should not be stripped: |
| 12 | |
| 13 | .. code-block:: html+twig |
| 14 | |
| 15 | {{ some_html|striptags('<br><p>') }} |
| 16 | |
| 17 | In this example, the ``<br/>``, ``<br>``, ``<p>``, and ``</p>`` tags won't be |
| 18 | removed from the string. |
| 19 | |
| 20 | .. note:: |
| 21 | |
| 22 | Internally, Twig uses the PHP `strip_tags`_ function. |
| 23 | |
| 24 | Arguments |
| 25 | --------- |
| 26 | |
| 27 | * ``allowable_tags``: Tags which should not be stripped |
| 28 | |
| 29 | .. _`strip_tags`: https://secure.php.net/strip_tags |