Reputation: 13
I have an array of objects:
objects = [
{
name: "a",
val: 1
},
{
name: "b",
val: 2
}
]
I'm trying to produce the following HTML with Handlebars:
<ul>
<li> <a href="#a">...</a> </li>
<li> <a href="#b">...</a> </li>
</ul>
If I didn't need the hash, I would do it like this:
<ul>
{{#objects}}
<li> <a {{bindAttr href="name"}}>...</a> </li>
{{/objects}}
</ul>
I can't use href="#name"
or href=#"name"
. Is there a way to get the hash in front of the name property?
Upvotes: 1
Views: 486
Reputation: 47367
<ul>
{{#each item in objects}}
<li> <a href="#{{unbound item.name}}">...</a> </li>
{{/each}}
</ul>
But i'm not sure what you're doing, you probably want to use the link-to helper
Upvotes: 1