- Guides & Documentation
Knowledgebase
Featured articles, how-to guides and quick tips.
Render HTML Special Characters with Twig Striptags in Drupal
Twig's striptags is a quick, easy solution for stripping markup directly via a template file in Drupal.
But one of the inadvertent consequences of using this technique is that HTML special characters are no longer rendered appropriately.
To get around this issue, simply change your syntax from:
{{ render|striptags }}
To this, instead:
{{ render|striptags|convert_encoding('UTF-8', 'HTML-ENTITIES') }}