简体   繁体   中英

MailJet: A template language occurred when sending a message using Template [ID]

While testing a MailJet email template with a simple custom html code block. The received test email throws an error. (Live preview in browser works fine)

From templating-language-error@mailjet.com :

A template language occurred when sending a message using Template [ID]: expression parsing error ## Unknown identifier: object.field1 ## near ## {{ object.field1 ##

The following code is used inside the html block:

 {% for object in var:objects %} <tr> <td>{{ object.field1 }}</td> <td>{{ object.field2 }}</td> <td>{{ object.field3 }}</td> <td>{{ object.field4 }}</td> </tr> {% endfor %}

The following data is used for testing:

 { "Data": {}, "Variables": { "objects": [ { "field1": "field1 value 1", "field2": "field2 value 1", "field3": "field3 value 1", "field4": "field4 value 1" }, { "field1": "field1 value 2", "field2": "field2 value 2", "field3": "field3 value 2", "field4": "field4 value 2" } ] } }

I don't understand what's wrong with this. Help is welcome, Thanks!

I'm having the same issue. Try changing it to:

{% for object in var:objects %}
  <td>{{ object.field1 }}</td>
  <td>{{ object.field2 }}</td>
  <td>{{ object.field3 }}</td>
  <td>{{ object.field4 }}</td>
{% endfor %}

That worked for me.

Okay the problem for me was in the text-mode editor. Because by default the setting 'Autogenerate plain text version' is on, but the text version doesn't support the for loop.

So, when the text version was auto generated, the for loop has been removed but the variables, like in your example {{ object.field1 }} stayed. And that was causing the error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM