{% if pagination and pagination.pages > 1 %}
<div class="pagination">
  <form method="get" class="pagination-form">
    {% if preserved_query is defined %}
      {% for item in preserved_query %}
      <input type="hidden" name="{{ item.key }}" value="{{ item.value }}">
      {% endfor %}
    {% else %}
    {% if q is defined %}<input type="hidden" name="q" value="{{ q }}">{% endif %}
    {% if status_filter is defined %}<input type="hidden" name="status_filter" value="{{ status_filter }}">{% endif %}
    {% if date_from is defined %}<input type="hidden" name="date_from" value="{{ date_from }}">{% endif %}
    {% if date_to is defined %}<input type="hidden" name="date_to" value="{{ date_to }}">{% endif %}
    {% if category_filter is defined %}<input type="hidden" name="category_filter" value="{{ category_filter }}">{% endif %}
    {% if sort is defined %}<input type="hidden" name="sort" value="{{ sort }}">{% endif %}
    {% if table_filters is defined %}
      {% for item in table_filters %}
      <input type="hidden" name="f_field" value="{{ item.field }}">
      <input type="hidden" name="f_op" value="{{ item.op }}">
      <input type="hidden" name="f_value" value="{{ item.value }}">
      {% endfor %}
    {% endif %}
    {% if table_sorts is defined %}
      {% for item in table_sorts %}
      <input type="hidden" name="sort_field" value="{{ item.field }}">
      <input type="hidden" name="sort_dir" value="{{ item.dir }}">
      {% endfor %}
    {% endif %}
    {% endif %}
    <input type="hidden" name="per_page" value="{{ pagination.per_page }}">
    <button class="btn" name="page" value="{{ pagination.page - 1 }}" {% if not pagination.has_prev %}disabled{% endif %}>‹</button>
    <span class="muted">Страница {{ pagination.page }} из {{ pagination.pages }} · всего {{ pagination.total }}</span>
    <button class="btn" name="page" value="{{ pagination.page + 1 }}" {% if not pagination.has_next %}disabled{% endif %}>›</button>
  </form>
</div>
{% else %}
  {% if pagination %}<div class="pagination muted">Всего {{ pagination.total }}</div>{% endif %}
{% endif %}
