From ed83c2cad515a8c933071a86110735ec54a5844e Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Mon, 23 Oct 2023 07:25:49 -0400 Subject: [PATCH] Add kwargs support to vite_react_refresh --- django_vite/templatetags/django_vite.py | 18 ++++++++++++++---- .../templatetags/test_vite_react_refresh.py | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/django_vite/templatetags/django_vite.py b/django_vite/templatetags/django_vite.py index fdb3304..1289a11 100644 --- a/django_vite/templatetags/django_vite.py +++ b/django_vite/templatetags/django_vite.py @@ -540,12 +540,16 @@ def _generate_vite_server_url(path: str) -> str: ) @classmethod - def generate_vite_react_refresh_url(cls) -> str: + def generate_vite_react_refresh_url(cls, **kwargs) -> str: """ Generates the script for the Vite React Refresh for HMR. Only used in development, in production this method returns an empty string. + Keyword Arguments: + **kwargs {Dict[str, str]} -- Adds new attributes to generated + script tags. + Returns: str -- The script or an empty string. """ @@ -553,7 +557,9 @@ def generate_vite_react_refresh_url(cls) -> str: if not DJANGO_VITE_DEV_MODE: return "" - return f"""