Now, my question: with text data, this approach works fine. However, with dates, this doesn’t appear to work. Do I have to do some additional manipulation first before putting the dates in a string?
You assign the var str_AlleLeidinggevenden_Mandaten_Startdata but in the test you use another variable called arr_AlleLeidinggevenden_Mandaten_Startdata
Is this the reason?
Also, if it’s exactly the output of some code you want to display in another template, you could also use a capture:
{% capture dates_directors %}
{% for person in period.directors %}
{% if person.director_start_date == empty %}{{colours_red}}geen begindatum{% else %}{{person.director_start_date | date:'%d/%m/%Y'}}{% endif %}
{% comment %}Step: stel voor de leidinggevenden de begindatum van het mandaat vast{% endcomment %}
{% if person.director_start_date == empty %}
{% assign str_AlleLeidinggevenden_Mandaten_Startdata = str_AlleLeidinggevenden_Mandaten_Startdata | append:'geen begindatum' | append:'|' %}
{% else %}
{% assign str_AlleLeidinggevenden_Mandaten_Startdata = str_AlleLeidinggevenden_Mandaten_Startdata | append:{{person.director_start_date}} | append:'|' %}
{% endif %}
{% endfor %}
{% endcapture %}
{% result 'dates_directors' dates_directors %}