mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-26 13:20:54 -05:00
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).
16 lines
381 B
HTML
16 lines
381 B
HTML
{% macro ajax_block(partials, url, key, interval=2, finished=False) %}
|
|
{% if not finished %}
|
|
<div
|
|
data-module="update-content"
|
|
data-resource="{{ url }}"
|
|
data-key="{{ key }}"
|
|
data-interval-seconds="{{ interval }}"
|
|
aria-live="polite"
|
|
>
|
|
{% endif %}
|
|
{{ partials[key]|safe }}
|
|
{% if not finished %}
|
|
</div>
|
|
{% endif %}
|
|
{% endmacro %}
|