{% macro comments_input(category, user, perms, reply_to) %} {% set reply_mode = reply_to is not null %}
{% if reply_mode %} {% endif %}
{{ user.username }}
{% if not reply_mode %} {% if perms.can_pin %} {% endif %} {% if perms.can_lock %} {% endif %} {% endif %}
{% endmacro %} {% macro comments_entry(comment, indent, category, user, perms) %} {% if comment.comment_deleted is null or comment.comment_replies|length > 0 %}
{{ comment.username }} {% if comment.comment_pinned is not null %} {% spaceless %} Pinned {% if comment.comment_pinned != comment.comment_created %} {% endif %} {% endspaceless %} {% endif %}
{{ comment.comment_deleted is null ? comment.comment_text|nl2br : 'deleted' }}
{% if comment.comment_deleted is null and user is not null %}
{% if perms.can_vote %} Like {% if comment.comment_likes > 0 %} ({{ comment.comment_likes|number_format }}) {% endif %} Dislike {% if comment.comment_dislikes > 0 %} ({{ comment.comment_dislikes|number_format }}) {% endif %} {% endif %} {% if perms.can_comment %} {% endif %} {% if perms.can_delete_any or (comment.user_id == user.user_id and perms.can_delete) %} Delete {% endif %} {# if user is not null %} Report {% endif #}
{% endif %}
{% from _self import comments_entry, comments_input %} {% if user|default(null) is not null and category|default(null) is not null and perms|default(null) is not null and perms.can_comment %} {{ comments_input(category, user, perms, comment) }} {% endif %} {% if comment.comment_replies is defined and comment.comment_replies|length > 0 %} {% for reply in comment.comment_replies %} {{ comments_entry(reply, indent + 1, category, user, perms) }} {% endfor %} {% endif %}
{% endif %} {% endmacro %} {% macro comments_section(comments, category, user, perms) %}
{% if user|default(null) is null %}
Please login to comment.
{% elseif category|default(null) is null or perms|default(null) is null %}
Posting new comments here is disabled.
{% elseif not perms.can_lock and category.category_locked is not null %}
This comment section was locked, .
{% elseif not perms.can_comment %}
You are not allowed to post comments.
{% else %} {% from _self import comments_input %} {{ comments_input(category, user, perms) }} {% endif %}
{% if perms.can_lock and category.category_locked is not null %}
This comment section was locked, .
{% endif %}
{% if comments|length > 0 %} {% from _self import comments_entry %} {% for comment in comments %} {{ comments_entry(comment, 1, category, user, perms) }} {% endfor %} {% else %}
There are no comments yet.
{% endif %}
{% if perms.can_delete %} {% endif %} {% if perms.can_comment %} {% endif %} {% if perms.can_vote %} {% endif %} {% endmacro %}