{# Reusable macros for answer-table pattern: summary, table with selection, bulk actions bar, and pagination controls. Usage in a page: {% from "partials/answer_table_macros.html" import results_summary, pagination, answer_table, bulk_actions_bar %}
{{ results_summary(start_index, end_index, total) }}
{% set headers = [ { 'title': 'Name', 'width': '220px' }, { 'title': 'Company' }, { 'title': 'Address' }, { 'title': 'City' }, { 'title': 'State', 'width': '80px' }, { 'title': 'ZIP', 'width': '110px' }, { 'title': 'Phones', 'width': '200px' }, { 'title': 'Actions', 'width': '140px', 'align': 'end' }, ] %} {% call(answer_table(headers, form_action='/reports/phone-book', select_name='client_ids', enable_bulk=enable_bulk)) %} {# render ... rows here #} {% endcall %} {% if enable_bulk %} {% call(bulk_actions_bar()) %} {# render bulk action buttons/links here #} {% endcall %} {% endif %} {{ pagination('/rolodex', page, total_pages, page_size, {'q': q, 'phone': phone}) }} #} {% macro results_summary(start_index, end_index, total) -%} {% if total and total > 0 %} Showing {{ start_index }}–{{ end_index }} of {{ total }} {% else %} No results {% endif %} {%- endmacro %} {% macro answer_table(headers, form_action=None, select_name='selected_ids', enable_bulk=False) -%}
{% if enable_bulk %} {% endif %} {% for h in headers %} {{ h.title }} {% endfor %} {{ caller() }}
{%- endmacro %} {% macro bulk_actions_bar() -%}
{{ caller() }}
{%- endmacro %} {% macro pagination(base_url, page, total_pages, page_size, params=None) -%} {% if total_pages and total_pages > 1 %} {% endif %} {%- endmacro %}