we are building our emails with mailJet which works fine so far. Our current problem is, that we would like to have a loop within a loop within a loop (so nested loops) the first loop works fine, and also the second inner loop is working fine, but the third one isn't working anymore:
{% for trip in var:trips %}
{{trip.id}}
{% for tripSegment in trip.tripSegments %}
{% for tripBreak in tripSegment.breaks %}
{{tripBreak.duration}}
{% endfor %}
{% endfor %}
Distance: {{trip.totalDistance}} km
{% endfor %}
This is in our template. If I remove the inner loop with the breaks, everything is fine.
If I enable the Template Error Reporting I get the following message:
X-MJ-ErrorMessage: "tripSegment.breaks" is not an array value
but if I try to print it with {{tripSegment.breaks}} I get the message:
X-MJ-ErrorMessage: Array values cannot be printed: tripSegment.breaks
and the field is definetly an array, like the trips or tripSegments, so basically it should work.
What am I doing wrong for nested loops in MailJet?
Edit:
My Object Structure, I send to Mailjet looks like this:
"Vars": {
"trips": [
"id": 1,
"tripSegments":[
{
"id":2,
"distance": 100,
"breaks":[
{
"duration":15
},{
"duration":20
}
]
},{
"id":3,
"distance": 200,
"breaks":[
{
"duration":10
},{
"duration":30
}
]
},{
"id":4,
"distance": 200,
"breaks":[
]
},
]
]
}
As we were in discussion with the MailJet Support [1], it turns out that there is a bug in the WYSIWYG editor of MailJet.
the multiple nested loops work, if you use them within a HTML Block and not directly in the WYSIWYG Editor.
They are working on that.
[1] https://app.mailjet.com/support/ticket/21e111b3be8630214cc082845f6cf976