Here is sample json attached for an iteration. json.txt (5.1 KB)
and here is my loop in the view with HANDLEBARS in express js
<div>
{{# each items }}
<article class="item">
<div>
<table>
<tr>
<td>
{{this._id}} // THIS PRINTS
</td>
{{# each data}}
<td>{{this.mPC}}</td> // THIS DOES NOT PRINT
{{/each}}
</tr>
<table>
</div>
</article>
{{/each}}
</div>
What I am doing wrong in above code so that THIS DOES NOT PRINT in the above code ?
{{# each data}}
<td>{{this.mPC}}</td> // THIS DOES NOT PRINT
{{/each}}
Is it not printing because there is no ādataā? i.e. the <td></td> arenāt there?
Or is there no āthis.mPCā i.e. <td></td> are there, but empty?
Well ignoring the strict validation that keys should be double-quote-wrapped strings
and that string values should be double-quote instead of single-quote wrapped,
your ID value is an unquoted string,
several (all?) of your floating point numbers are wrapped in quotes. Not strictly a malformation, but it might confuse some code if you try and do math with it.
youāre trying to use this JSON as a list, but the JSON isnt wrapped in a list container,
Yeah, see, the JSON you provided us starts with a {, not a [. So items is not a list, itās an object.
Here is your code, working correctly, with a properly formatted JSON. I have made no modifications to the template, just added some CSS so i can actually see the resulting cells clearly.
So you may need to examine what ādocā is (console.log(doc)) before it gets handed to the template engine.
Hey much thanks for solution bro. I was facing this problem for many days in Wordpress. I read many forums about the solution regarding the schema. I donāt know about mongoose schema before but I must say alot of thanks for your efforts. Also, my site was having some issues which got fixed.