留着小胡子遍历数组 [英] Iterating over arrays with mustache

查看:74
本文介绍了留着小胡子遍历数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在迭代中获取对当前元素的引用?

How do I obtain a reference to the current element in the iteration?

{{#my_array}}
    <p>{{__what_goes_here?__}}</p>
{{/my_array}}

我希望我只是忽略了明显的东西.

I hope I am just overlooking the obvious.

推荐答案

根据规范的changelog ,则在规范的v1.1.0中添加了隐式迭代器(.).每个至少实现v1.1.0的Mustache库都应支持此功能.

According to the spec's changelog, the implicit iterator (.) was added in v1.1.0 of the spec. Every Mustache library that implements at least v1.1.0 should support this.

{{#array_of_strings}}<li>{{.}}</li>{{/array_of_strings}}

这篇关于留着小胡子遍历数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆