diff --git a/docs/macros.rst b/docs/macros.rst index 63f13dbd..5807947e 100644 --- a/docs/macros.rst +++ b/docs/macros.rst @@ -491,6 +491,7 @@ API caption=None,\ table_classes=None,\ header_classes=None,\ + body_classes=None,\ responsive=False,\ responsive_class='table-responsive',\ safe_columns=None,\ @@ -512,6 +513,7 @@ API :param caption: A caption to attach to the table. :param table_classes: A string of classes to apply to the table (e.g ``'table-small table-dark'``). :param header_classes: A string of classes to apply to the table header (e.g ``'thead-dark'``). + :param body_classes: A string of classes to apply to the table body (e.g ``'table-group-divider'``). :param responsive: Whether to enable/disable table responsiveness. :param responsive_class: The responsive class to apply to the table. Default is ``'table-responsive'``. :param safe_columns: Tuple with columns names to render HTML safe using ``|safe``. diff --git a/examples/bootstrap5/templates/table.html b/examples/bootstrap5/templates/table.html index bc7e33eb..0c579426 100644 --- a/examples/bootstrap5/templates/table.html +++ b/examples/bootstrap5/templates/table.html @@ -7,8 +7,8 @@

Simple Table

{{ render_table(messages) }}

Customized Table

-
{% raw %}{{ render_table(messages, titles, table_classes='table-striped', header_classes='thead-dark', caption='Messages') }}{% endraw %}
-{{ render_table(messages, titles, table_classes='table-striped', header_classes='thead-dark', caption='Messages') }} +
{% raw %}{{ render_table(messages, titles, table_classes='table-striped', header_classes='thead-dark', body_classes='table-group-divider', caption='Messages') }}{% endraw %}
+{{ render_table(messages, titles, table_classes='table-striped', header_classes='thead-dark', body_classes='table-group-divider', caption='Messages') }}

Responsive Table

{% raw %}{{ render_table(messages, responsive=True, responsive_class='table-responsive-sm') }}{% endraw %}
diff --git a/flask_bootstrap/templates/base/table.html b/flask_bootstrap/templates/base/table.html index b22647bb..47e42b60 100644 --- a/flask_bootstrap/templates/base/table.html +++ b/flask_bootstrap/templates/base/table.html @@ -30,6 +30,7 @@ caption=None, table_classes=None, header_classes=None, + body_classes=None, responsive=False, responsive_class='table-responsive', safe_columns=None, @@ -75,7 +76,7 @@ {% endif %} - + {% for row in data %} {% for title in titles %} diff --git a/tests/test_bootstrap4/test_render_table.py b/tests/test_bootstrap4/test_render_table.py index 6fb3299b..596a1df8 100644 --- a/tests/test_bootstrap4/test_render_table.py +++ b/tests/test_bootstrap4/test_render_table.py @@ -125,13 +125,15 @@ def test(): return render_template_string(''' {% from 'bootstrap4/table.html' import render_table %} {{ render_table(messages, titles, table_classes='table-striped', - header_classes='thead-dark', caption='Messages') }} + header_classes='thead-dark', body_classes='table-group-divider', + caption='Messages') }} ''', titles=titles, messages=messages) response = client.get('/table') data = response.get_data(as_text=True) assert '' in data assert '' in data + assert '' in data assert '' in data
Messages