How to iterate through array inside HTML template?

How to iterate through array inside HTML template?

If you have array of objects in the input data like this:

{
   "items": [
      {
        "name": "T-800 Prototype Research",
        "price": 1000.0
      },
      {
        "name": "T-800 Cloud Sync Setup",
        "price": 300.0
      }
    ]
}

Then you may easily iterate these objects like this

{{#each items}}
    Name: {{name}}, Price: {{price}}
{{/each}}

Useful for creating tables with data like this:

<table>
    {{#each items}}
        <tr>
        <td>{{name}}</td>
        <td>{{price}}</td>
        </tr>
    {{/each}}
</table>
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.