Reputation: 11
<% var percentage = (data.skills[i].rating / 10) * 100 %>
<div class="progress">
<% var style = `style=width: percentage%` %>
<div class="progress-bar color-1" role="progressbar" aria-valuenow="%= percentage %>"
aria-valuemin="0" aria-valuemax="10" <%= style %>>
<span><%= percentage %>%</span>
</div>
</div>
Upvotes: 0
Views: 78
Reputation: 5704
You need to use <%-
for unescaped strings instead of <%=
for style to work <%- style %>
.
You forgot a <
in front of %=
here aria-valuenow="%= percentage %>
Also i'm not sure what you think this does style=width: percentage%
since percentage%
is just a string which will not be replaced by ejs engine.
So the correct code should look like bellow:
<% var percentage = (5 / 10) * 100 %>
<div class="progress">
<% var style = `style="width: ${percentage}px"` %>
<div class="progress-bar color-1" role="progressbar" aria-valuenow="<%= percentage %>"
aria-valuemin="0" aria-valuemax="10" <%- style %>>
<span><%= percentage %>%</span>
</div>
</div>
You can paste the code in this playground to see what the output is.
Upvotes: 1