feat: add "simple", "prepend", and "append" render types (#1156)

* feat: add "simple", "prepend", and "append" render types

* refactor: explicitly set strategy for "document" in tests
This commit is contained in:
Juro Oravec 2025-05-02 15:07:16 +02:00 committed by GitHub
parent e74e1241ac
commit bf7a204e92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 1210 additions and 408 deletions

View file

@ -25,6 +25,7 @@ class Calendar(Component):
kwargs={
"date": request.GET.get("date", ""),
},
deps_strategy="append",
)
@ -52,4 +53,5 @@ class CalendarRelative(Component):
kwargs={
"date": request.GET.get("date", ""),
},
deps_strategy="append",
)

View file

@ -107,7 +107,7 @@ class FragmentBaseHtmx(Component):
class FragJs(Component):
class View:
def get(self, request):
return FragJs.render_to_response(request=request, type="fragment")
return FragJs.render_to_response(request=request, deps_strategy="fragment")
template: types.django_html = """
<div class="frag">
@ -131,7 +131,7 @@ class FragJs(Component):
class FragAlpine(Component):
class View:
def get(self, request):
return FragAlpine.render_to_response(request=request, type="fragment")
return FragAlpine.render_to_response(request=request, deps_strategy="fragment")
# NOTE: We wrap the actual fragment in a template tag with x-if="false" to prevent it
# from being rendered until we have registered the component with AlpineJS.

View file

@ -25,4 +25,5 @@ class CalendarNested(Component):
kwargs={
"date": request.GET.get("date", ""),
},
deps_strategy="append",
)