meteor-jade
meteor-jade copied to clipboard
Accessing Array Content
This works:
{{emails.[0].address}}
This doesn't:
#{emails.[0].address}
Is this a bug with meteor-jade or is my syntax wrong?
Is that something we want? It's not a valid JavaScript syntax, the normal syntax should be #{emails[0].address}
. I'm not sure if it already works today, but if it doesn't you can still use the spacebars alternative. I don't think I want to support the #{emails.[0].address}
syntax in jade.
I know that meteor-jade
behavior is little different of pure jade
, but I think you wrote wrong!!
- var emails = [{"name": "a", "address": "a@a"}, {"name": "b", "address": "b@b"}]
p #{emails[0].name} - #{emails[0].address}
p #{emails[1].name} - #{emails[1].address}
hr
ul
each email in emails
li #{email.name} - #{email.address}
http://codepen.io/lagden/pen/QwjojM?editors=100
I think Meteor used to allow emails.0.address
at around 0.7, but switched to emails.[0].address
with Blaze at 0.8+, probably some weirdness when parsing through complex objects/arrays ?
Either way for consistency sake why not do #{emails.0.address}
at least ? Also the valid javascript syntax would be emails[0].address
if we want to equate it to that one.
At least a note about array/object access would be really nice - I had to google foo this hard for 15+ minutes.