I have a rich text field which contains:


This is what is left when you delete all content of a redactor field. This can't be deleted without the HTML view of Redactor.

Is it possible to write a conditional that checks for an empty field ignoring HTML markup?

{% if entry.poorText is not empty %}
   {{ entry.poorText }}
{% endif %}

Does not work in this case.

1 Answer 1


You can use the striptags filter to remove all HTML tags from your string. With the trim filter you can strip all whitespace from the beginning and the end of it:

{% if entry.poorText|striptags|trim %}
    {{ entry.poorText }}
{% else %}
    Here could be a nicely formatted text! 
{% endif %}
  • 1
    in twig, an empty string evaluates to false, so you could just test {% if entry.poorText|striptags|trim %} Dec 18, 2014 at 18:06
  • Right. Thx @Marion.
    – carlcs
    Dec 18, 2014 at 18:12

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.