Skip to content

Nested Template Condition #100

@hsuanweifu

Description

@hsuanweifu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions