{% macro avatar(user) %} {% if user is empty %} Avatar {% elseif user is not object %} Avatar {% else %} {% if user|default({photo: null}).photo %} Avatar {% elseif user and user|trim != 'Unknown User' %} {% set initials = [] %} {% for word in user|trim|split(' ') %} {% set initials = initials|merge([word[:1]|upper]) %} {% endfor %}
{{ initials|slice(0, 2)|join('') }}
{% else %} Avatar {% endif %} {% endif %} {% endmacro %} {% macro displayAvatarText(user, text) %}
{{ _self.avatar(user) }} {{ text|raw }}
{% endmacro %} {% macro displayCard(icon, creator, title, body, time = null) %}
{% if icon %}
{{ icon }}
{% else %} {{ _self.avatar(creator) }} {% endif %}
{% if time is not empty %} {{ time }} {% endif %} {{ title|raw }}
{% if body is not empty %} {{ body|render_html|raw }} {% else %} <no body> {% endif %}
{% endmacro %} {% macro displayFile(file) %}
{% if file.mimeType in ['image/png', 'image/gif', 'image/jpeg', 'image/jpg', 'image/heic'] %} {{ file }} {% else %}
{{ file }}
{% endif %}
{{ file.name }}
{{ file.fileSize|filesize }}
{% endmacro %} {% macro displayFiles(files) %} {% if files|length %} {% for file in files %} {% if loop.index0 is divisible by(3) %} {% endif %} {% if (loop.index0 + 1) is divisible by(3) or loop.last %} {# Close row and pad with empty cells if needed #} {% set remaining = 3 - ((loop.index0 + 1) % 3) %} {% if loop.last and remaining < 3 %} {% for i in 1..remaining %} {% endfor %} {% endif %} {% endif %} {% endfor %}
{{ _self.displayFile(file) }}
{% endif %} {% endmacro %} {% macro displayCommentBody(comment, includeFiles = false) %}
{{ comment.body|render_html|raw }}
{% if comment.poll|default(null) %}

{{ comment.poll }}

{% for option in comment.poll.options %}
{{ option }}
{% endfor %}
{% endif %} {% if includeFiles and comment.files|default(null) %} {{ _self.displayFiles(comment.files) }} {% endif %} {% endmacro %} {% macro displayComment(comment) %} {{ _self.displayCard( null, comment.creator, comment.creator|default({name: 'Unknown User'}).name ~ ' added a comment', _self.displayCommentBody(comment, true)|trim, comment.createdAt|date(receiver.timeFormat|default('h:i A')) ) }} {% endmacro %}