Derive markup dashboard from rendered partials

This commit extends the `ajax_block` component to take a `dict` of
partials, from which it can select the partial matching its `key`
argument and print its HTML to the page.

This means that the same markup is only rendered in one place, rather
than in two (individually in the JSON endpoint and as `include`s in the
parent template).
This commit is contained in:
Chris Hill-Scott
2016-06-28 11:23:43 +01:00
parent fa01c1bc5c
commit ccf520f446
5 changed files with 92 additions and 114 deletions

View File

@@ -1,4 +1,4 @@
{% macro ajax_block(url, key, interval=2, finished=False) %}
{% macro ajax_block(partials, url, key, interval=2, finished=False) %}
{% if not finished %}
<div
data-module="update-content"
@@ -8,7 +8,7 @@
aria-live="polite"
>
{% endif %}
{{ caller() }}
{{ partials[key]|safe }}
{% if not finished %}
</div>
{% endif %}