{# adapted from https://codepen.io/redlabor/pen/wyiAH which is a fork of https://codepen.io/jamesbarnett/pen/vlpkh #}
{% if not rate_error %}
<div class="rate" data-entry-id={{ entry.id }} hx-vals='{"entryId": {{ entry.id }} }'>
    {% set rating = entry.rating * 2 if entry.rating is not none else 0 %}
    {% for i in range(10, 0, -1) %}
    <a href="#" class="rate-star fas{{ ' half' if i % 2 == 1 else '' }}{{' star-active' if i <= rating else '' }}"
        hx-post="{{ url_for('main.rate_entry') }}"
        hx-target="closest .rate"
        hx-swap="outerHTML"
        hx-vals='{"rating": {{ i/2 }} }'
        title="{{ (i/2)|string }} stars"></a>
    {% endfor %}
</div>
{% else %}
<div class="rate-error">{{ rate_error }}</div>
{% endif %}
