Add example of template rendering to TableBlock docs

Addresses #5540
pull/5615/head
Matt Westcott 2019-09-04 15:36:56 +01:00 zatwierdzone przez LB
rodzic 72ba719ac8
commit a0035c33c0
3 zmienionych plików z 26 dodań i 1 usunięć

Wyświetl plik

@ -23,6 +23,7 @@ Changelog
* Added ARIA role to TableBlock output (Matt Westcott)
* Added cache-busting query parameters to static files within the Wagtail admin (Matt Westcott)
* Allow `register_page_action_menu_item` and `construct_page_action_menu` hooks to override the default menu action (Rahmi Pruitt, Matt Westcott)
* Add docs table template rendering example (Matt Westcott)
* Fix: Added line breaks to long filenames on multiple image / document uploader (Kevin Howbrook)
* Fix: Added https support for Scribd oEmbed provider (Rodrigo)
* Fix: Changed StreamField group labels color so labels are visible (Catherine Farman)

Wyświetl plik

@ -26,7 +26,7 @@ Basic Usage
After installation, the TableBlock module can be used in a similar fashion to other StreamField blocks in the Wagtail core.
Just import the TableBlock ``from wagtail.contrib.table_block.blocks import TableBlock`` and add it to your StreamField declaration.
Import the TableBlock ``from wagtail.contrib.table_block.blocks import TableBlock`` and add it to your StreamField declaration.
.. code-block:: python
@ -35,6 +35,29 @@ Just import the TableBlock ``from wagtail.contrib.table_block.blocks import Tabl
table = TableBlock()
Then, on your page template, the ``{% include_block %}`` tag (called on either the individual block, or the StreamField value as a whole) will render any table blocks it encounters as an HTML ``<table>`` element:
.. code-block:: html+django
{% load wagtailcore_tags %}
{% include_block page.body %}
Or:
.. code-block:: html+django
{% load wagtailcore_tags %}
{% for block in page.body %}
{% if block.block_type == 'table' %}
{% include_block block %}
{% else %}
{# rendering for other block types #}
{% endif %}
{% endfor %}
Advanced Usage
--------------

Wyświetl plik

@ -42,6 +42,7 @@ Other features
* Added ARIA role to TableBlock output (Matt Westcott)
* Added cache-busting query parameters to static files within the Wagtail admin (Matt Westcott)
* Allow ``register_page_action_menu_item`` and ``construct_page_action_menu`` hooks to override the default menu action (Rahmi Pruitt, Matt Westcott) - thanks to `The Motley Fool <https://www.fool.com/>`_ for sponsoring review of this feature
* Add docs table template rendering example (Matt Westcott)
Bug fixes