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.
Activity