I just started to use mustache.js, I have my json dictionary, my html template, and my mustache.js startup code to inject the whole. My html-mustache template is such:
<script id="tpl" type="text/html">
<div class="body">
<p>{{口.zht}}</p>
<p>{{口.sam.pyn}}</p>
<p>{{口.sam.fra}}</p>
</div>
</script>
In my test case with a given existing entry '口', it works (1). But I notice that Mustache seems designed to iterate all the JSON entries. However, I want to work on a small focusList of entries
var focusList = ['們','火山口','火'];
for which I want to pick the corresponding data from my larger (~1000 entries) JSON dictionary.
How can I change or make variable {{#口}} and {{/口}} according to my focusList, so I may print my template with the correct data?
Is there some kinds of variables in the template such:
<script id="tpl" type="text/html">
<div class="body">
<p>{{{{entry}}.zht}}</p>
<p>{{{{entry}}.sam.pyn}}</p>
<p>{{{{entry}}.sam.fra}}</p>
</div>
</script>
and in the JS I add:
var entry = focusList[Math.floor(Math.random() * focusList.length)]]
?