Created
June 9, 2016 09:16
-
-
Save armetiz/ca707522ba5d491c184fdbeb92f67c26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro stars(rating, max) %} | |
<div class="stars"> | |
{% for i in range(1, max) %} | |
{% set toggled = (i <= rating|round) %} | |
{% set half = (rating|round == i and rating|round(0, 'floor') != rating) %} | |
{% if half %} | |
{% set className = "fa-star-half-o" %} | |
{% elseif toggled %} | |
{% set className = "fa-star" %} | |
{% else %} | |
{% set className = "fa-star-o" %} | |
{% endif %} | |
<i class="fa fa-2x {{ className }}" aria-hidden="true"></i> | |
{% endfor %} | |
</div> | |
{% endmacro %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment