refactor: render fragment explicitly
Instead of including the template for non-hx-requests, inject the rendered fragment.
This commit is contained in:
@@ -6,14 +6,16 @@
|
||||
<p>A new old way to build web applications</p>
|
||||
</hgroup>
|
||||
<table>
|
||||
{% if users.is_some() %}
|
||||
{% include "fragment/user/table.html" %}
|
||||
{% else %}
|
||||
<tr><td>
|
||||
<button hx-get="/user" hx-target="table" hx-push-url="true">
|
||||
Load data
|
||||
</button>
|
||||
</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% match fragment %}
|
||||
{% when Some with (fragment) %}
|
||||
{{ fragment|safe }}
|
||||
{% when None %}
|
||||
<tr><td>
|
||||
<button hx-get="/user" hx-target="table" hx-push-url="true">
|
||||
Load data
|
||||
</button>
|
||||
</td></tr>
|
||||
{% endmatch %}
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user