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

Nested {{#each}} loop for templates do not display the right JSON object in Test Data #403

Open
Jack2804 opened this issue Jan 28, 2024 · 1 comment

Comments

@Jack2804
Copy link

Hi. So i'm trying to create an email template for my webapp, and I encounter this issue where nested {{#each}} fails to generate a right JSON object for test data. I couldn't find the limitation anywhere in a doc. It is possible to do nested {{#each}} in Mailgun?

image

image

@olexandr-mazepa
Copy link
Collaborator

olexandr-mazepa commented Feb 15, 2024

Hi @Jack2804
I did a check and nested loops seems working fine.
At least the next template is working:

<table>
      {{#each all_services}}
        <tr>{{this.service_description}}</tr>
        {{#each this.service_items}}
          <td>{{this.aaa}}</td>
          <td>{{this.bbb}}</td>
        {{/each}}
      {{/each}}
</table>

I used the next data shape for it:

"all_services": [
  {
    "service_items": [
      {
        "aaa": "test_array_item_aaa",
        "bbb": "test_array_item_bbb"
      }
    ],
    "service_name": "service_name",
    "service_description": "service_description"
  }
]

The result is next:
image

Based on provided screenshots you are missing service_items array to iterate through.

You can use the next doc to get familiar with Handlebars templating language. https://handlebarsjs.com/guide/#what-is-handlebars

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