From 1cb5b994d4786470a0d57c2bc39f63a921fdca4b Mon Sep 17 00:00:00 2001 From: Bijay Nayak Date: Fri, 25 Aug 2023 21:18:16 +0530 Subject: [PATCH] Feat: Make the HTMX object available in templates as a global context variable & FIX: #26 --- flask_htmx/htmx.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flask_htmx/htmx.py b/flask_htmx/htmx.py index 34e07be..84e3836 100644 --- a/flask_htmx/htmx.py +++ b/flask_htmx/htmx.py @@ -25,6 +25,10 @@ def init_app(self, app: Flask): """Initialise the extension with the Flask app object.""" app.htmx = self + @app.context_processor + def htmx_context_processor(): + return {'htmx': self} + @property def boosted(self) -> bool: """:py:obj:`True` if the request came from an element with the `hx-boost`