You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
how to make template to detect empty richtext fields #600
Hello.
I am trying to do something like this for each entry (e) in my template:
{% for e in entries %} {{ e.country }}:{{ e.locality }}{%r if e.habitat %}; {{r e.habitat }}{%r endif %}{% if e.substrate %}; {{ e.substrate }}{% endif %}.
{% endfor %}
Basically, I want habitat & substrate fields to be printed preceded by a separator ';' (but ONLY if those fields contain a text; otherwise, the separator and field shouldn't be printed).
This is a simplified version of my code (I generate my context from a database and I apply RichText using a function depending on some other factors).
But the Honolulu entry illustrates my problem: is there a way my template can detect that RT("", color="blue") is actually an empty text entry, so the {%r if e.habitat %} should not be executed?
Currently, I am getting this text output (I am not showing the bold/italics/coloured output here, since that's not the problem: please notice the double ; separator after Honolulu):
USA: Boston; forest; wood.
USA: New Orleans; marsh.
USA: Honolulu; ; water.
USA: St. Louis; ship; water.
USA: New York!; concrete.
@abubelinha in docform (the maintained fork) an empty RichText is now falsy, so {%r if e.habitat %} skips RT("", color="blue") just like "" and the doubled ; goes away. That's cvas22/docform#205. Until then a workaround here is {%r if e.habitat and e.habitat.xml %}, though that's true for an empty run with formatting too.
Activity
cvas22 commentedon Nov 25, 2026
@abubelinha in docform (the maintained fork) an empty RichText is now falsy, so
{%r if e.habitat %}skipsRT("", color="blue")just like""and the doubled;goes away. That's cvas22/docform#205. Until then a workaround here is{%r if e.habitat and e.habitat.xml %}, though that's true for an empty run with formatting too.