Bad:
<div class="comment">
<div class="message">some message</div>
<div class="rate {% if comment.rate > 0%}green{% elseif comment.rate < 0 %}red{% else %}gray{% endif %}">{{ comment.rate }}</div>
</div>
Good:
{% set rateClass = comment.rate > 0 ? 'green' : comment.rate < 0 ? 'red' : 'gray' %}
<div class="comment">
<div class="message">some message</div>
<div class="rate {{ rateClass }}">{{ comment.rate }}</div>
</div>
Or:
{% if comment.rate > 0 %}
{% set rateClass = 'green' %}
{% elseif comment.rate < 0 %}
{% set rateClass = 'red' %}
{% else %}
{% set rateClass = 'gray' %}
{% endif %}
<div class="comment">
<div class="message">some message</div>
<div class="rate {{ rateClass }}">{{ comment.rate }}</div>
</div>