[英]How to render one element of an array in mustache
If I have an object like 如果我有像这样的对象
z = {"sname":"mike","lname":"michael","V":[1,2,3,4,5]};
Is there some way to specify that one element of V
is to be rendered? 有没有办法指定要渲染
V
一个元素? What goes in the template in place of ?????
什么在模板中取代
?????
? ?
T = <p>V={{#V}}{{.}} {{/V}} but V[3]={{?????}}</p>
If this is not possible, it would be useful to know that. 如果这是不可能的,那么知道这将是有用的。
I can always construct separate V_0, V_1, V_2, V-3, V_4 entries but that seems VERY ugly. 我总是可以构建单独的V_0,V_1,V_2,V-3,V_4条目,但这看起来非常难看。
how about using lambdas to do the same. 如何使用lambdas做同样的事情。 Although I am not very thorough about using partial I am guessing you could do this:
虽然我不是很透彻使用部分我猜你可以这样做:
{
"partial": function() {
return function(array) {
return render(array[3]);
}
}
}
{{#partial}}
{{.}}
{{/partial}}
Hope I got this right.. 希望我做对了..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.