Mustache.js - 显示键而不是值
我在这里使用这些数据: http://pastie.org/3231052 - 如何显示密钥而不是使用小胡子或车把的价值?
[{"interval":"2012-01-21",
"advertiser":"Advertisers 1",
"offer":"Life Insurance",
"cost_type":"CPA",
"revenue_type":"CPA",
... etc ...
}]
I am using this data here: http://pastie.org/3231052 - How can I display the key instead of the value using Mustache or Handlebars?
[{"interval":"2012-01-21",
"advertiser":"Advertisers 1",
"offer":"Life Insurance",
"cost_type":"CPA",
"revenue_type":"CPA",
... etc ...
}]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你想显示键值对,你可以在Handlebars中编写一个helper。
编辑
似乎这并不完全是你想要的,但有可能想出一个可以解决这个问题的助手。
If you want to display key-value pairs, you can write a helper in Handlebars.
EDIT
Seems like this isn't quite what you want, but it's possible to come up with a helper that will do the trick.
我使用 Handlebars 修改了之前的响应来处理对象键值对。它就像执行以下操作一样简单:
我在 Fiddle 上举了一个例子,希望它可以帮助那里的人。请注意,此实现取决于 Handlebars
Mustache 属性添加。
I modified the previous response using Handlebars to handle objects key value pair. It is as simple as just doing the following:
I put an example on Fiddle, hope it helps someone out there. Please note this implementation depends on Handlebars
Mustache Attribute addition.