Reputation: 5773
I am new to handlebar.js. i want to access the Home.Names.Id while am iterating through Home.Room in handlebar template.
but am getting empty value.
{{#Home.Room}}
{{Home.Names.id}}
{{/Home.Fip}}
am i missing anything here? I need your valuable suggestions.
Upvotes: 1
Views: 412
Reputation: 434665
When you do this:
{{#x}}
{{y}}
{{/x}}
Handlebars will be looking for y
inside x
so the data would need to look like this:
x: { y: ... }
or like this:
x: [ { y: ... }, { y: ... } ]
If you want to look for y
in the namespace above x
, you can say ../y
:
{{#x}}
{{../y}}
{{/x}}
In your case:
{{#Home.Room}}
{{../Home.Names.id}}
{{/Home.Room}}
I'm assuming that the Fip
in your question is just a copy'n'paste typo BTW.
Demo (open your console): http://jsfiddle.net/ambiguous/NCUnP/
Upvotes: 2