0

I'm trying to create a Mailjet template with an array of flat objects. But during my tests, Mailjet send me this kind of error:

expression parsing error ## Unknown identifier: session.name ## near ## {{session.name ##

For details, below my current template:

<table class="result">
    <thead>
        <tr>
            <th>Name</th>
            <th>Status</th>
            <th>details</th>
        </tr>
    </thead>
    <tbody>
      {% for session in var:result.sessions %}
    <tr>
      <td>{{session.name}}</td>
      <td>
        {% if session.status == "Error" %}
        <span class="error-icon"/>
        {% else %}
        <span class="success-icon"/>
        {% endif %}
      </td>
      <td>{{session.details}}</td>
    </tr>
      {% endfor %}
    </tbody>
</table>

{% if var:result.error != "" %}
    <span>Erreur during the process : {{var:result.error}}</span>
{% endif %}

And below, the variables I try to pass during my test:

{
    "Variables":
    {
        "result":
        {
            "error": "An error occurred foo bar blabla",
            "sessions": [
              {
                  "name": "A nice session",
                  "status": "Error",
                  "details": "This session is broken"
              }
            ]
        }
    }
}

I even tried to use <mj-raw> tags around my mjml markups, but it changes nothing. I've tested my template by curl request and with my account's Mailjet sandbox.

Have you got an idea?

1 Answers1

0

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 {{ session.name }} stayed. And that was causing the error.

You have to check the text-version for the errors.

Jochem Gruter
  • 2,813
  • 5
  • 21
  • 43