I'm trying to create a table from data that I get from querying a mongoDB. The data has the following structure:
[
{ team_shortName: 'Liverpool', position: 1, overall_points: 99 },
{ team_shortName: 'Man City', position: 2, overall_points: 81 },
{ team_shortName: 'Chelsea', position: 4, overall_points: 66 },
{ team_shortName: 'Leicester', position: 5, overall_points: 62 },
{ team_shortName: 'Man Utd', position: 3, overall_points: 66 },
]
I want to use the keys in the array as headers for the table, but can't figure out how to access and display them using handlebars. Here is how I want my table to look like
<table class="bordered highlight centered" style="border: 1px solid black">
<thead>
<tr>
<th>{{ #DISPLAY HEADERS }}</th>
</tr>
</thead>
<tbody>
{{#each result}}
<tr>
<td>{{this.team_shortName}}</td>
<td>{{this.position}}</td>
<td>{{this.overall_points}}</td>
</tr>
{{/each}}
</tbody>
</table>
rendered table would look like this
team_shortName position overall_points
Liverpool 1 99
Man City 2 81
Chealsea 4 66
Leicester 5 62
Man Utd 4 66