E 'facile per scorrere un array con Handlebars.js come:Esiste un metodo per iterare una mappa con Handlebars.js?
{{#each comments}}
<div class="comment">
<h2>{{title}}</h2>
{{{{url}}}
</div>
{{/each}}
e una serie come:
{
comments: [
{ url: "http://www.yehudakatz.com", title: "Katz Got Your Tongue" },
{ url: "http://www.sproutcore.com/block", title: "SproutCore Blog" },
]
}
Ma io non trovare un metodo per scorrere una mappa simile:
{
headers: {
"Host": "www.example.com",
"Location": "http://www.example.com",
... Much more map items ...
}
}
Esiste un metodo per iterare una mappa con Handlebars.js? O devo restructurate l'oggetto come:
{
headers: [
{ key: "Host", value: "www.example.com" },
{ key: "Location", value: "http://www.example.com" },
]
}
possibile duplicato di [Handlebars/Moustache: esiste un modo integrato di scorrere le proprietà di un oggetto?] (Http://stackoverflow.com/questions/9058774/handlebars-mustache-is-there-a -built-in-way-to-loop-through-the-properties-of) – Jon
Visitatori futuri: ora è disponibile il supporto integrato per iterare una mappa in Handlebars. La domanda collegata ha i dettagli. – Jon