mustachio icon indicating copy to clipboard operation
mustachio copied to clipboard

Nesting help

Open grosch opened this issue 8 years ago • 0 comments

I have a template like so:

<table border="1" class="alternate">
    <thead style="background-color: #aaa8f0">
        <th>Station Name</th>
        {{#each abbrevs}}
        <th>{{name}}</th>
        {{/each}}
    </thead>
    <tbody>
        {{#each orders}}
        <tr>
           <td>{{station}}</td>
        </tr>
        {{/each}}
    </tbody>
</table>

And then my data model has something like this:

{
  "abbrevs" : [
     { "name" : "ud" },
    { "name" : "dp" }
  ],
  "orders: [
     {
        "station" : "...",
       "ud" : 1,
       "dp" 2
    },
    {
      ...
    }
  ]
}

So in the headers I'm adding a column for each of the abbrevs names. Now, when I'm looping through my orders, I'm not sure how to put the proper value in the proper column for the order.

grosch avatar Aug 04 '16 20:08 grosch