{% set likes = post.likers | length %}
{# the likers are fetched when the modal opens, so a page of posts never loads them. Every swap attribute is set here, because the post menu sits inside the topic page's element that sets the swap targets of its moderation actions. #} {{ _("%(count)s like%(plural)s", count=likes, plural="" if likes == 1 else "s") }} {% if can_like %} {% set action = url_for('like.unlike_post' if already_liked else 'like.like_post', post_id=post.id) %} {# swaps this widget through htmx. Every swap attribute is set here, because the post menu sits inside the topic page's element that sets the swap targets of its moderation actions. #}
{{ form.hidden_tag() }} {% if already_liked %} {% else %} {% endif %}
{% endif %}