{% from "macros/user.html" import m_user_photo, m_user_link %} {% from "macros/form.html" import m_field %} {% macro m_comments(entity) %} {%- if comments.has_comments(entity) %}
    {%- for comment in comments.for_entity(entity) %}
  1. {{ m_comment(comment) }}
  2. {%- endfor %}
{%- endif %} {% endmacro %} {# single comment #} {% macro m_comment_edit_link(comment) %} {%- if g.user == comment.owner or g.is_manager %} {{ _('Edit') }} {%- endif %} {% endmacro %} {% macro m_comment_delete_link(comment) %} {%- if g.user == comment.owner or g.is_manager %} {{ _('Delete') }} {%- endif %} {% endmacro %} {% macro m_comment(comment) %}
{%- call m_user_link(comment.creator) %} {{ m_user_photo(comment.creator, size=45) }} {%- endcall %} {%- call m_user_link(comment.creator, css='author') %} {{ comment.creator.name }} {%- endcall %} {{ comment.created_at | age }}

{{ comment.body | linkify | paragraphs }}

{{ m_comment_edit_link(comment) }} {{ m_comment_delete_link(comment) }} {%- set count = comment.history |length %} {%- if comment.history %} {{ _n('edited', 'edited %(count)d times', count, count=count) }} {%- endif %}
{% endmacro %} {% macro m_comment_form(entity) %} {%- set ctx = comments.get_form_context(entity) %}
{%- for field in ctx.form %} {{ m_field(field) }} {%- endfor %}
{%- for button in ctx.buttons %} {{ button.render() }} {%- endfor %}
{% endmacro %}