{% macro render_link(link) %}
{{link.title}}
{% for tag in link.tags|sort %} {{tag}} {% endfor %} {% for related in link.related %} {{related.title}} {% endfor %} {% if link.archive %}archive.org{% endif %} {% if link.page %}{% endif %}
{% if link.abstract %}
{{link.abstract}}
{% endif %} {% endmacro %} {% macro render_ungrouped(links) %} {% for link in links %} {{render_link(link)}} {% endfor %} {% endmacro %} {% macro render_grouped(all, groups) %} {# Group index #}
All {% for tag, links in groups %} {{tag|default("other", True)|capitalize}} {% endfor %}
{# Post groups #}
{% for tag, coll in groups %}
{{tag|default("other categories", True)|capitalize}}
{{render_ungrouped(coll)}} {% endfor %}
{# Tag list #}
Tags
{% for tag, card in all.tags_and_cards() %} {{tag}} {{card}} {% endfor %}
{% endmacro %} {% macro render_links(all, groups) %}
{% if groups|length == 1 %} {{render_ungrouped(all)}} {% else %} {{render_grouped(all, groups)}} {% endif %}
{% endmacro %}