Got the question just today: I don’t want to list all the directors in my text template. I would rather display them in one singular sentence, like “Tim, Joris, Sven”
Is this possible? Yes it is
If you take this code :
{% for person in period.directors %}
{{ person.name }}
{% endfor %}
it will result in this :
With the stripnewlines attribute we can strip all these lines, and put them in one sentence.
Just place the attribute before and after your code to do that :
{% stripnewlines %}
{% for person in period.directors %}
{{ person.name }},
{% endfor %}
{% endstripnewlines %}
And the result will be like this :
Jack it up a little bit with a sentence and to end with an ‘and’ :
The directors of the company are:
{% for person in period.directors %}
{% if forloop.last %}
and
{% else %}
{% unless forloop.first %}
,
{% endunless %}
{% endif %}
{{ person.name }}
{% endfor %}
{% endstripnewlines %}
to look like this :
Credits to @SamVanEenoo for this too