I’m trying to create a tree from a list of tags which have tags inside them.
Here’s a sample of the JSON I’m using :
{
"tags":
[{"name":"My first tag",
"tags":
[{"name":"My first tag inside a tag"},
{"name":"My second tag inside a tag"}]
}]
}
If I use the following mustache template, it displays “My first tag” without any problems :
<ul>
{{#tags}}
<li tag-id="{{id}}">
{{name}}
</li>
{{/tags}}
</ul>
But then, using the following template, I’m trying to display the tags inside this first tag :
<ul>
{{#tags}}
<li tag-id="{{id}}">
{{name}}
<div>
{{#tags}}
<a>{{name}}</a>
{{/tags}}
</div>
</li>
{{/tags}}
</ul>
Using this template, Mustache doesn’t render anything.
How do I display nested lists using Mustache?
To solve that issue, I will do:
I hope that helps