Make a macro for the AJAX update module

This is less repetitive than typing out the HTML with all its attributes
every time.

It also lets us wrap up the idea of ‘finished’ as a parameter, so the
AJAX code will only be initiated when it’s needed, eg if a job is still
processing.
This commit is contained in:
Chris Hill-Scott
2016-06-28 09:21:46 +01:00
parent c761d57d1d
commit fa01c1bc5c
7 changed files with 53 additions and 68 deletions

View File

@@ -0,0 +1,15 @@
{% macro ajax_block(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 %}
{{ caller() }}
{% if not finished %}
</div>
{% endif %}
{% endmacro %}