是否有任何选项可以使用一些定义变量来设置 mustache 标签?像这样的东西:
json
{
"color_set_01": [
"white", "black"
],
"color_set_02": [
"green", "red"
]
}
JavaScript
var color = 'color_set_' + options.number;
$.getJSON('json/data.json', function(data) {
var template = "<ul>{{color}}<li class="{{.}}"></li>{{/color}}</ul>";
var html = Mustache.to_html(template, data);
colors_panel.html(html);
});
和想要的结果,如果它是color_set_01
aray
<div class="colors_panel">
<ul>
<li class="white">
<li class="black">
</ul>
</div>