MailJet嵌套循环 [英] MailJet nested loops
问题描述
{%for var in trip}}
{{trip.id}}
$
{{tripBreak.duration}}
{%endfor%b $ b { }
{%endfor%}
距离:{{trip.totalDistance}} km
{%endfor%}
这是我们的模板。如果我删除内部循环与休息,一切都很好。
如果我启用模板错误报告我得到以下消息:
X-MJ-ErrorMessage:tripSegment.breaks不是数组值
但是,如果我尝试使用{{tripSegment.breaks}}打印它,我会收到以下消息:
X-MJ-ErrorMessage:无法打印数组值:tripSegment.breaks
和该字段是一个数组,像tripps或tripSegments一样,所以基本上应该可以正常工作。
我在MailJet中嵌套循环做错什么?
编辑:
我的对象结构,我发送到Mailjet看起来像这样:
$ b $
id:1,
tripSegments:[
$ {
id:2,
distance:100,
break:[
{
持续时间:15
},{
duration:20
}
]
},{
id:3,
distance:200,
break:[
{
duration:10
},{
duration:30
}
]
},{
id:4,
distance:200,
break:[
]
},
]
]
}
正如我们在与MailJet支持[1]的讨论中,事实证明,MailJet的WYSIWYG编辑器中有一个错误。
多个嵌套循环工作,如果您使用它们在HTML块内,而不是直接在所见即所得编辑器中。
他们正在努力。
[1] https://app.mailjet.com/support/ticket/21e111b3be8630214cc082845f6cf976
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
这篇关于MailJet嵌套循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!