I think it used to let me, not sure what changed? I cannot use logic inside of a Mailjet Template "For" loop. it does not like my FormatNumber
or if
My Vars:
"Variables": {
"CurrentYear": "",
"OutstandingInvoices": [{"InvoiceNum": "100", "Total": 100.00, "DaysPastDue": "5", "InvoiceMonth": "May", "InvoiceYear": "2021"}],
"CustomerID": "",
"CustomerName": "",
"InvoiceYear": "",
"InvoiceMonth": ""
}
}
My Template Code:
{% for invoice in var:OutstandingInvoices %}
{{invoice.InvoiceMonth}} {{invoice.InvoiceYear}} for {{FormatNumber("$#,###.00", invoice.Total)}} {% if invoice.DaysPastDue > 0 %} : {{invoice.DaysPastDue}} days late {% endif %}
{% endfor %}
Gives me the following errors:
(1) ERender Error: Expression Parsing Error: Unknown identifier invoice.Total near FormatNumber("$#,###.00", invoice.Total)
(2) ERender Error: Expression Parsing Error: Unknown identifier invoice.DaysPastDue near invoice.DaysPastDue > 0
Misc
I wonder if it is related to not being able to use default values in for loops as well (as per my other question: Mailjet Non-Nested Loop Failing)
So logic of any kind is not allowed in a for loop?