I'm looking to purge all the html from a text field, but leave the line breaks in there. I currently have the following code, which makes line breaks happen, but unfortunately, people can add html to the text field and it will render it.

    {{ user.userAbout|raw }}

Is there any way to do this?

1 Answer 1


Sounds like you're looking for the Twig |striptags filter, which is a wrapper for PHP's strip_tags

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.