I am not really sure how to get data out of this nested object with Mustache.js. I am using the YQL multi query that brings back my data objects nested https://gist.github.com/866247. My problem comes when I am trying to access the nested objects
The data comes back like this where 0 and 1 are part of an array with objects in them. Here is a picture of the tree http://cl.ly/1e1b3O3U233e2I0d3g2f.
query
results
results
0
1
I have tried the template below and I don’t get anything back. I believe the problem is that that second “results key” comes back with the array and mustache doesn’t know what to do.
"{{#query}}
{{#results}}
{{#results}}
{{#photo}}
{{farm}}
{{#photo}}
{{/results}}
{{/results}}
{{/query}}"
If this makes sense to anyone, how do I access the nested objects in the array if there is no key to them?
I think you should flatten your data into a simpler format to write a template that makes sense, but you can get pretty close to what you want with it as-is.
The one insurmountable issue I saw was that ‘results’ is inside ‘results’ resulting in a tag closure mismatch. Doing something like this solves that problem:
A functional sample is here.
You can find some more mustache tricks in this article.