Mailjet Non-Nested Loop Failing

风流意气都作罢 提交于 2021-01-29 20:30:41

问题


My test email for a Mailjet Template keeps failing in a for loop I am using. Unlike other Mailjet Loop questions on stack overflow, my loops are not nested, and my array is not empty.

The following code keeps failing

In my template, I have two template blocks (for the for and endfor) surrounding a text block. Like below:

    {{var:FirstName:""}}

    {% for month in var:MonthList %}

    {{month.Name:""}} {{month.Count:""}}

    {% endfor %}

I keep getting:

    ERenderError: expression parsing error ## Unknown Identifier: month.Name:"" ## near...

When testing the template I am using ExpertMode for updating variables in the Preview Email section.

    [{"Month": "March", "Count", 4}]

Can anyone see what is going wrong? I've looked into the documentation and read all issues in StackOverflow regarding MailJet loops, and I can't figure out what is wrong.


回答1:


After so many frustrating hours, I figured out what was wrong as I was about to post this question. Hope it helps someone save some time.

In a for loop, you cannot give a value a default value. For instance {{var:FirstName:""}} is ok outside of the for loop, but {{month.Name:""}} is NOT okay inside the for loop.



来源:https://stackoverflow.com/questions/60124419/mailjet-non-nested-loop-failing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!