flask-htmx
flask-htmx copied to clipboard
Make the HTMX object available in templates as a global context variable
For example:
from flask_htmx import HTMX
htmx = HTMX(app)
Now in Flask's Jinja templates, a htmx
variable is available. This is useful for such cases where conditionals are required to render certain blocks of HTML in the Jinja templates.
{% if htmx %}
<div id="app" hx-swap-oob="true">...</div>
{% endif %}
This is useful when paired with using Jinja's include
tag and htmx's hx-boost
and hx-swap-oob
attributes.