{% from 'bootstrap/utils.html' import render_icon %} {% macro deprecate_old_pk_placeholder() %} {{ warn('The default action primary key placeholder has changed to ":id", please update. The support to the old value (":primary_key") will be removed in version 2.0.') }} {% endmacro %} {% macro render_table(data, titles=None, primary_key='id', primary_key_title='#', caption=None, table_classes=None, header_classes=None, responsive=False, responsive_class='table-responsive', show_actions=False, actions_title='Actions', custom_actions=None, view_url=None, edit_url=None, delete_url=None, new_url=None, action_pk_placeholder=':id') %} {% if not titles %} {% set titles = get_table_titles(data, primary_key, primary_key_title) %} {% endif %} {% if responsive %}
{% endif %} {% if caption %} {% endif %} {% for title in titles %} {% endfor %} {% if show_actions %} {% endif %} {% for row in data %} {% for title in titles %} {% if title[0] == primary_key %} {% else %} {% endif %} {% endfor %} {% if show_actions %} {% endif %} {% endfor %}
{{ caption }}
{{ title[1] }}{{ actions_title }} {% if new_url %} {{ render_icon('plus-circle-fill') }} {% endif %}
{{ row[title[0]] }}{{ row[title[0]] }} {% if custom_actions %} {% for (action_name, action_icon, action_url) in custom_actions %} {% if ':primary_key' in action_url %} {% set action_pk_placeholder = ':primary_key' %} {% set w = deprecate_old_pk_placeholder() %} {% endif %} {{ render_icon(action_icon) }} {% endfor %} {% endif %} {% if view_url %} {% if ':primary_key' in view_url %} {% set action_pk_placeholder = ':primary_key' %} {% set w = deprecate_old_pk_placeholder() %} {% endif %} {{ render_icon('eye-fill') }} {% endif %} {% if edit_url %} {% if ':primary_key' in edit_url %} {% set action_pk_placeholder = ':primary_key' %} {% set w = deprecate_old_pk_placeholder() %} {% endif %} {{ render_icon('pencil-fill') }} {% endif %} {% if delete_url %} {% if ':primary_key' in delete_url %} {% set action_pk_placeholder = ':primary_key' %} {% set w = deprecate_old_pk_placeholder() %} {% endif %}
{{ render_icon('trash-fill') }}
{% endif %}
{% if responsive %}
{% endif %} {% endmacro %}