I have get json data from external api.
<h4>ChangePercent <span class="badge bg-secondary"> {{ stock.changePercent}} % </span></h4>
Code above is get response data json and it's return with number type, and use template engine with express handlebars to render. It's work , But.. I want to change font color red if stock.changePercent < 0 , green for stock.changePercent > 0
You can conditionally render in handlebarsjs
Template:
<h4>ChangePercent <span class="badge bg-secondary" {{#if stockChangeSmallerThanZero}}style="color: red;"{{/if}}> {{ stock.changePercent}} % </span></h4>
Variable
{
stockChangeSmallerThanZero: true,
}