Ank*_*kur 6 string list handlebars.js
我有一个字符串列表,我想用Handlebars.js显示
到目前为止,这似乎是不可能的,尽管这应该是这种情况似乎很荒谬.
product对象的一个例子是:
"product": {
"name": "top TP-209-NAV",
"category": "Top",
"brand": "Living Dolls",
"description": "Fabric : Navy-white stretch cotton Long sleeves top (can be worn as dress)",
"price": "23.0",
"tags": [
"Slips on",
" stretch cotton",
" long sleeves"
],
"image1": {
"src": "http://www.livingdolls-closet.com/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/T/P/TP-209-NAV-1-living-dolls-top_1.jpg",
"ratio": 1.5
}
},
Run Code Online (Sandbox Code Playgroud)
我想迭代并显示tags列表中的项目.
当我做这样的事情时,我可以看到适当数量的逗号,表明列表正在迭代,但是我无法弄清楚如何显示实际的标签项.
{{#product.tags}}<a href="">{{val}}</a>, {{/product.tags}}
Run Code Online (Sandbox Code Playgroud)
Ank*_*kur 16
我只需要使用each帮手..
{{#each product.tags}}<a href="">{{this}}</a>, {{/each}}
Run Code Online (Sandbox Code Playgroud)