I first use widthratio tag to calculate a ratio percentage number and assgign it to a variable named Ratio Then when I try to compare it with an integer in if and elif tag, the if and elif tag seems all goes false, and I alway go to the final else tag and get the wrong result. Below is my source code:
<div class="container-fluid">
<p><span class="icon-group"></span> Player registratered: {{event.Players_registratered}}/{{event.Max_players}}</p>
{% widthratio event.Players_registratered event.Max_players 100 as Ratio %}
{{Ratio}}
<div class="progress progress-striped active text-center">
{% if Ratio < 30 %}
<div class="progress-bar progress-bar-info" role="progressbar"
aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:{{Ratio}}%">
</div>
{% elif Ratio < 70 %}
<div class="progress-bar progress-bar-success" role="progressbar"
aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:{{Ratio}}%">
</div>
{% elif Ratio < 90 %}
<div class="progress-bar progress-bar-warning" role="progressbar"
aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:{{Ratio}}%">
</div>
{% else %}
<div class="progress-bar progress-bar-danger" role="progressbar"
aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:{{Ratio}}%">
</div>
{% endif %}
</div>
</div>
and the output snip:Wrong output
I hope someone could answer it. Thank you very much.
else
condition each time, all bars would be 100%.with
in the beginning of yourwithratio
tag ? like this:{% with widthratio event.Players_registratered event.Max_players 100 as Ratio %}
with
andendwith
tag before 'if' and 'endif', but the problem still exist. The variable Ratio seems exist all the way with out using 'with' tag.