{% extends "named.jinja" %}

{% block header %}
    
    {{ super() }}

    {% if mode == 'full' %}
        <div class="description">{{ content.description.render() }}</div>
        {% with tree = content.tree() %}
            {% if tree.children|length %}
                {{ tree.render('teaser') }}
            {% else %}
                <p>This tag has no children.</p>
            {% endif %}
        {% endwith %}
    {% endif %}

{% endblock %}


{% block content %}

    {% if mode == 'full' %}

        <div class="posts">
        {% with tagged_posts = content.list_tagged() %}

            {% if not tagged_posts.results|length %}
                <article><div class="content"><p>No associated content.</p></div></article>
            {% else %}
                <ul class="tagged-posts listing">
                {% for post in tagged_posts.results %}
                    <li>{{ post.render('teaser') }}</li>
                {% endfor %}
                </ul>

                {% if tagged_posts.menu %}
                    {{ tagged_posts.menu.render() }}
                {% endif %}
            {% endif %}

        {% endwith %}

    {% else %}
        <div class="description">{{ content.description.render() }}</div>
    {% endif %}

{% endblock %}

{% block footer %}
{% if mode != 'full' %}
This tag has {{ content.list_tagged().results|length }} posts associated with it.
{% endif %}
{% endblock %}
