adammark/Markup.js

Recursive items aren't iterated

quintenvk opened this issue · 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?

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