fitzgen / fitzgen/tempest

Nested loops only work if they have the same number of variables

Open
#12 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
22
Forks
2
PR merge metrics
No merged PRs in 30d

Description

When using a template like this, everything works fine:

```
{% for paragraph in paragraphs %}
{{ paragraph.title }}
{{ paragraph.body }}
{% for image in paragraph.images %}
{{ image.src }} {{ image.alt }}
{% endfor %}
{% endfor %}
```

But when I use a template like this, the browser ends-up in a never ending loop.

```
{% for paragraph in paragraphs %}
{{ paragraph.title }}
{% for image in paragraph.images %}
{{ image.src }} {{ image.alt }}
{% endfor %}
{% endfor %}
```

The data I use is:

```
var data = {
"email": "contact@roelkramer.nl",
"name": "Roel Kramer",
"subject": "blaat",
"footer": "footer blah blah",
"paragraphs": [{
"title": "test paragraph title 1",
"body": "test paragraph body 1",
"images": [
{"src": "http 1", "alt": "img alt"},
{"src": "http 2", "alt": "img alt"},
{"src": "http 3", "alt": "img alt"}
]
},
{
"title": "test paragraph title 2",
"body": "test paragraph body 2",
"images": [
{"src": "http 1", "alt": "img alt"},
{"src": "http 2", "alt": "img alt"}
]
},
{
"title": "test paragraph title 3",
"body": "test paragraph body 3",
"images": [
{"src": "http 1", "alt": "img alt"},
{"src": "http 2", "alt": "img alt"}
]
}
]
};
$("#campaign-edit-mode").html($.tempest("campaign-template", data));
```

I hope this can be fixed.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.