How do i color a specific row in a table depending on the value in that row?
{{#each files}}
<tr>
<td style="text-align:left">{{filename}}</td>
{{#if status === "Completed"}}
<td style="text-align:right color:green">{{status}}</td>
{{#else status === "Pending"}}
<td style="text-align:right color:yellow">{{status}}</td>
</tr>
{{/each}}
I loop through a list of files and i want to color the status depending if the value is completed or the value is pending?
First you'll need to make an equality helper if you aren't already using one:
Handlebars.registerHelper({
eq: (v1, v2) => v1 === v2,
});
Then use it in the loop:
{{#each files}}
<tr style="{{if (eq "Completed" status) "color:green"}} {{if (eq "Pending" status) "color:yellow"}}">
<td>{{filename}}</td>
<td>{{status}}</td>
</tr>
{{/each}}