Change minify-html details to be more spec compliant

This commit is contained in:
Jake Howard 2024-05-04 23:07:35 +01:00
parent b89b9d0797
commit 514e609973
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 11 additions and 2 deletions

View file

@ -0,0 +1,9 @@
from django_minify_html.middleware import MinifyHtmlMiddleware
class CustomMinifyHtmlMiddleware(MinifyHtmlMiddleware):
minify_args = {
"do_not_minify_doctype": True,
"ensure_spec_compliant_unquoted_attribute_values": True,
"keep_spaces_between_attributes": True,
}

View file

@ -38,7 +38,7 @@ class SearchPageTestCase(TestCase):
self.assertEqual(search_input.attrs["name"], "q")
self.assertEqual(search_input.attrs["hx-get"], "results/")
self.assertEqual(search_input.attrs.get("value", ""), "")
self.assertNotIn("value", search_input.attrs) # Because of minify-html
self.assertEqual(len(soup.select(search_input.attrs["hx-target"])), 1)
self.assertEqual(len(soup.select(search_input.attrs["hx-indicator"])), 2)

View file

@ -100,7 +100,7 @@ MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"enforce_host.EnforceHostMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django_minify_html.middleware.MinifyHtmlMiddleware",
"website.common.middleware.CustomMinifyHtmlMiddleware",
"django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",