Insert HTML table to a placeholder
larrybg opened this issue · comments
I have a simple report.handlebar file:
<!DOCTYPE html>
<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td,
th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<p>{{reportDate}}</p>
<p>{{htmlReportTable}}</p>
</body>
</html>`
The {{htmlReportTable}} is the HTML Table code that I create and pass to this placeholder, and it shows as a simple text when I receive email.
Here is the data that is passed to the placeholder (this html code is built from an array of data and represented as a String var):
<table>
<tr>
<th>Case Number</th>
<th>Assigned To</th>
<th>Hostname</th>
<th>IP</th>
</tr>
<tr>
<td>TS01</td>
<td>email1@u.com</td>
<td>vm064</td>
<td>10.1.0.1</td>
</tr>
<tr>
<td>TS21</td>
<td>email2@u.com</td>
<td>vm0632</td>
<td>10.1.0.2</td>
</tr>
<tr>
<td>TS03</td>
<td>email3@u.com</td>
<td>vm012</td>
<td>10.1.0.12</td>
</tr>
<tr>
<td>TS04</td>
<td>email4@u.com</td>
<td>vm069</td>
<td>10.1.0.19</td>
</tr>
</table>
Is there a way to pass to placeholder the HTML table string so it would show up in the email normal text and not as HTML code? Or there is another way to handle it?
I think wrapping the htmlReportTable
in a triple mustache should work: {{{htmlReportTable}}}
. See https://handlebarsjs.com/guide/#html-escaping