Email a table from PostreSQL data

Hi There
I am trying to send data from a PostgreSQL query via a HTML function through Email. The problem is to dynamically create the rows. Here is what i have so far in a standard template node.

Any advice would be appreciated

<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>

<h2>Dayly Alarms</h2>

<table id="table" border="1">
     <tr>
    <th>created</th>
    <th>device_type</th>
    <th>ack_by</th>
    <th>Ack_time</th>
    <th>alarm_type</th>
    <th>device_imei</th>
    <th>device_id</th>
    <th>site</th>
 </tr>

  <tr ng-repeat="row in msg.payload">
    <td>{{payload[prop].created}}</td>
    <td>{{payload[prop].device_type}}</td>
    <td>{{payload[prop].ack_by}}</td>
    <td>{{payload[prop].Ack_time}}</td>
    <td>{{payload[prop].alarm_type}}</td>
    <td>{{payload[prop].device_imei}}</td>
    <td>{{payload[prop].device_id}}</td>
    <td>{{payload[prop].site}}</td>
  </tr>
  
</table>

</body>

I think that is the ui template syntax

In the standard template use mustache syntax

[{"id":"be3f52ab.3c4e78","type":"inject","z":"57675e72.26a0d8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"created\":\"1\",\"device_type\":\"2\",\"ack_by\":\"3\"},{\"created\":1,\"device_type\":2,\"ack_by\":3},{\"created\":1,\"device_type\":2,\"ack_by\":3}]","payloadType":"json","x":140,"y":2720,"wires":[["2a62bb62.f0f7cc"]]},{"id":"2a62bb62.f0f7cc","type":"template","z":"57675e72.26a0d8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"\n<style>\ntable, th, td {\n  border: 1px solid black;\n}\n</style>\n\n\n\n<h2>Dayly Alarms</h2>\n\n<table id=\"table\" border=\"1\">\n     <tr>\n    <th>created</th>\n    <th>device_type</th>\n    <th>ack_by</th>\n </tr>\n    {{#payload}}\n  <tr>\n    <td>{{created}}</td>\n    <td>{{device_type}}</td>\n    <td>{{ack_by}}</td>\n  </tr>\n    {{/payload}} \n</table>\n\n","output":"str","x":310,"y":2700,"wires":[["662e84ea.e38f1c"]]},{"id":"662e84ea.e38f1c","type":"debug","z":"57675e72.26a0d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":2700,"wires":[]}]

http://mustache.github.io/mustache.5.html

  {{#payload}}
  <tr>
    <td>{{created}}</td>
    <td>{{device_type}}</td>
    <td>{{ack_by}}</td>
  </tr>
    {{/payload}} 

Thanks, it seems to be working perfect