Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behaviour of if and for loop. #676

Closed
apoorva-shah opened this issue May 16, 2017 · 1 comment
Closed

Unexpected behaviour of if and for loop. #676

apoorva-shah opened this issue May 16, 2017 · 1 comment

Comments

@apoorva-shah
Copy link

apoorva-shah commented May 16, 2017

So in my php code var:first is "no" so it should not go inside loop. But it executes for loop.

As var:low_price_low_stock_goods is empty array in mail i get error:

So mail gives error "No value for "var:low_price_low_stock_goods"="

{% if var:first == "yes" %} 
    {% for item in var:low_price_low_stock_goods %}
         <tr>
            <td width="350">{{ item.good_name }}</td>
                <td>{{ item.value }}</td>
                <td>{{ item.count }}</td>
          </tr>
     {% endfor %} 
{% endif %}
@ngarnier
Copy link
Member

Hi @apoorva-shah, consider providing more information when opening an issue, it makes it easier to help you.

I guess you're talking about Mailjet's templating language, please rather reach out to the Mailjet support team for next questions related to Mailjet's API, it doesn't belong to the MJML Github.

Anyway, it's a known issue on Mailjet's templating language, sorry for that. To avoid it, just pass a valid object in the API call for the low_price_low_stock_goods value. Even this will work:

{
  item.good_name: "",
  item.value: "",
  item.count: ""
}

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants