Skip to content

Commit

Permalink
Ensure all options passed to classes
Browse files Browse the repository at this point in the history
  • Loading branch information
danjac committed Apr 2, 2021
1 parent 01efb08 commit 0453aa6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/turbo_response/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# Local
from .constants import Action
from .frame import TurboFrame
from .renderers import BaseRenderer
from .response import HttpResponseSeeOther
from .stream import TurboStream, TurboStreamAction

Expand Down Expand Up @@ -91,9 +92,7 @@ class TurboStreamTemplateResponseMixin(TurboStreamMixin):
template_engine: Engine
get_template_names: Callable

def render_turbo_stream(
self, context: Dict[str, Any], **response_kwargs
) -> HttpResponse:
def render_turbo_stream(self, context: Dict[str, Any], **kwargs) -> HttpResponse:
"""Renders a turbo-stream template response.
:param context: template context
Expand All @@ -102,7 +101,7 @@ def render_turbo_stream(
return (
self.get_turbo_stream()
.template(self.get_template_names(), context, using=self.template_engine)
.response(self.request)
.response(self.request, **kwargs)
)


Expand Down Expand Up @@ -193,6 +192,9 @@ def get_turbo_stream_template_names(self) -> List[str]:
for template in self.get_template_names()
]

def get_turbo_stream_renderer(self) -> Optional[BaseRenderer]:
return None

def get_context_data(self, **kwargs) -> Dict[str, Any]:
# TurboStream response will automatically add this,
# but we also want to access it in the initial render
Expand All @@ -217,7 +219,7 @@ def render_turbo_stream_response(self, **context) -> HttpResponse:
context=self.get_context_data(**context),
using=self.template_engine,
)
.response(self.request)
.response(self.request, renderer=self.get_turbo_stream_renderer())
)

def form_invalid(self, form: forms.Form) -> HttpResponse:
Expand Down

0 comments on commit 0453aa6

Please sign in to comment.