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 Template Condition #100

Open
hsuanweifu opened this issue Jan 9, 2017 · 0 comments
Open

Nested Template Condition #100

hsuanweifu opened this issue Jan 9, 2017 · 0 comments

Comments

@hsuanweifu
Copy link

https://github.com/twigkit/tempo/blob/master/examples/nested-conditional-templates.html
On this example the second list does not show the expected result as it was shown on the first list.
I believe that it was caused by

```
   if (ready) {
            var foundTemplates = {};
            for (var s = 0; s < children.length; s++) {
                if (children[s].getAttribute !== undefined) {
                    if (utils.hasAttr(children[s], 'data-template-for') && children[s].getAttribute('data-template-for').length > 0 && this.nestedItem === children[s].getAttribute('data-template-for') && !foundTemplates[this.nestedItem]) {
                        // Nested template
                        this.createTemplate(children[s]);
                        // Guards against recursion when child template has same name!
                        foundTemplates[this.nestedItem] = true;
                    } else if (utils.hasAttr(children[s], 'data-template') && !utils.isNested(children[s])) {
                        // Normal template
                        this.createTemplate(children[s]);
                    }
                }
            }

What's the purpose of
                      // Guards against recursion when child template has same name!
                        foundTemplates[this.nestedItem] = true;

By updating foundTemplates[this.nestedItem] to false the problem seems to be fixed.

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

1 participant