如何查找手柄模板内的数组长度? [英] How to find Array length inside the Handlebar templates?

查看:87
本文介绍了如何查找手柄模板内的数组长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用json对象呈现的Handlebars模板。在这个JSON中,我发送一个数组。像这样:

I have a Handlebars template which is rendered using a json object. In this json I am sending an array. Like this:

var json = {
               "array":["abc","def","ghi","jkl"] 
}

现在在我的模板中,我想查找长度这个数组。例如:

Now in my template I want to find the length of this array. Something like:

{{#each item}}
   {{ array.length }}
{{/each}}

无法在Handlebars文档中找到它。

Couldn't find it in the Handlebars documentation.

推荐答案

我的坏......

{{array。长度}} 实际上在模板内工作。应该在发布之前检查/测试它。

{{array.length}} actually worked inside the template. Should have checked/tested it before posting it here.

这篇关于如何查找手柄模板内的数组长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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