问题
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