Markup.js icon indicating copy to clipboard operation
Markup.js copied to clipboard

Recursive items aren't iterated

Open quintenvk opened this issue 10 years ago • 1 comments

Suppose I have a JSON with the following structure:

{
    "items": [{
        "name": "item 1",
        "items": [{
            "name": "subitem 1"
        }, {
            "name": "subitem 2"
        }]
    }, {
        "name": "item 2"
    }]
}

In this case, I'd have a template like this:

{{items}}
        <li>
            {{name}}
            {{if items}}
            <ul>
                {{items}}
                <li>{{name}}</li>
                {{/items}}
            </ul>
            {{/if}}
        </li>
{{/items}}

However, the inner "items" aren't iterated over - the <ul>isn't even being shown. Could the parser be made recursive?

quintenvk avatar Mar 30 '15 09:03 quintenvk

Hm, I doubt it—not easily, anyway. If this is an absolute requirement for you, perhaps try Underscore templates, which allows arbitrary JavaScript. http://underscorejs.org/#template

adammark avatar Mar 30 '15 20:03 adammark