{% set posts = __SELF__.posts %}
{% set tag = __SELF__.tag %}

<h3>Search results for <i><strong>{% if tag %}{{ tag.name }}{% else %}{{ slug }}{% endif %}</strong></i></h3>

<ul class="post-list">
    {% for post in posts %}
        <li>
            <h3><a href="{{ post.url }}">{{ post.title }}</a></h3>

            <p class="info">
                Posted
                {% if post.categories.count %} in {% endif %}
                on {{ post.published_at|date('M d, Y') }} 
                <i class="glyphicon glyphicon-tags"></i>
                {% for tag in post.tags %}
                {{ tag.name }} {% if not loop.last %}, {% endif %}
                {% endfor %}
            </p>

            <p class="excerpt">{{ post.summary }}</p>
        </li>
    {% else %}
        <li class="no-data">{{ noPostsMessage }}</li>
    {% endfor %}
</ul>

{% if posts.lastPage > 1 %}
    <ul class="pagination">
        {% if posts.currentPage > 1 %}
            <li><a href="{{ this.page.baseFileName|page({ (pageParam): (posts.currentPage-1) }) }}">&larr; Prev</a></li>
        {% endif %}

        {% for page in 1..posts.lastPage %}
            <li class="{{ posts.currentPage == page ? 'active' : null }}">
                <a href="{{ this.page.baseFileName|page({ (pageParam): page }) }}">{{ page }}</a>
            </li>
        {% endfor %}

        {% if posts.lastPage > posts.currentPage %}
            <li><a href="{{ this.page.baseFileName|page({ (pageParam): (posts.currentPage+1) }) }}">Next &rarr;</a></li>
        {% endif %}
    </ul>
{% endif %}
