have already been through this SO solution (and many more) but to no avail:
How to iterate over array of objects in Handlebars?
Given this:
feeds: [
{
name: "Guardian",
data: "empty"
},
{
name: "TechCrunch",
data: [
{
"title": "Instagram is testing screenshot alerts for stories",
"author": "Fitz Tepper"
},
{
"title": "A group of industry insiders are putting Russian election meddling up for ad awards",
"author": "Jonathan Shieber"
},
{
"title": "The Trump administration is reportedly moving to privatize the International Space Station",
"author": "Jonathan Shieber"
}
]
},
{
name: "BBC",
data: "empty"
}
]
How do I fetch the "title" information from the "data" array? The "feeds" object is being passed to .hbs in the render param. So far, I've been able to come up with the following, which is showing up blank on the HTML/.hbs page:
.hbs
<div class="tab-pane fade in" id="{{name}}" role="tabpanel">
<div id="results">
<script id="data-template" type="text/x-handlebars-template">
<div>
{{#data}}
{{#each this}}
{{title}}
{{/each}}
{{/data}}
</div>
</script>
</div>
</div>
<script>
$(function () {
let source = $("#data-template").html();
let template = Handlebars.compile(source);
let html = template({{contents}});
$('#results').html(html);
}
);
</script>
Thank you for looking into this!