{% endif %}
{# Recursive macro for rendering comments and replies #}
{% macro render_comment(comment, is_reply=false) %}
{{ comment.author_username }}{{ comment.created_at.strftime('%Y-%m-%d %H:%M') }}
{% if not comment.is_deleted %}
{% if current_user.is_authenticated and comment.author_username == current_user.username %}
{% elif current_user.is_authenticated and current_user.is_admin() %}
{% endif %}
{% endif %}
{% if comment.is_deleted %}
{% if comment.deleted_by == 'admin' %}
[This comment has been removed by a moderator]
{% else %}
[This comment has been deleted by the author]
{% endif %}
{% else %}
{{ comment.content | urlize }}
{% if current_user.is_authenticated and comment.author_username == current_user.username %}
{% endif %}
{% endif %}
{# Reply button - available for all comments (deleted or not) #}
{% if current_user.is_authenticated %}
{% endif %}
{# Display nested replies recursively #}
{% if comment.replies %}
{% for reply in comment.replies %}
{{ render_comment(reply, is_reply=true) }}
{% endfor %}
{% endif %}
{% endmacro %}
{% set top_level_comments = video.comments | selectattr('parent_id', 'none') | list %}
{% if current_sort == 'oldest' %}
{% set top_level_comments = top_level_comments | reverse | list %}
{% endif %}
{% if top_level_comments %}
{% for comment in top_level_comments %}
{{ render_comment(comment) }}
{% endfor %}
{{ video.comments | selectattr('parent_id', 'none') | list | length }} Comments
Log in to post a comment.
{% endif %} {# Recursive macro for rendering comments and replies #} {% macro render_comment(comment, is_reply=false) %}{% for reply in comment.replies %} {{ render_comment(reply, is_reply=true) }} {% endfor %}
{% for comment in top_level_comments %} {{ render_comment(comment) }} {% endfor %}
{% else %}No comments yet. Be the first to comment!
{% endif %}