Skip to content

Commit d888b4d

Browse files
committed
Address lastoutstadnngcomment, and run black.
1 parent d432639 commit d888b4d

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/reactpy_django/templatetags/jinja.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
from reactpy_django import config
1010
from reactpy_django.templatetags.reactpy import component
1111

12+
#
13+
# Point to our non-Django analogue.
14+
#
15+
DJT_TEMPLATE = "reactpy/component.html"
16+
1217

1318
class ReactPyExtension(Extension):
1419
"""
@@ -17,7 +22,7 @@ class ReactPyExtension(Extension):
1722
1823
{{ component(*args, **kwargs) }}
1924
"""
20-
DJT_TEMPLATE = 'reactpy/component.html'
25+
2126
#
2227
# Therefore, there is no new tag to parse().
2328
#
@@ -31,7 +36,9 @@ def __init__(self, environment):
3136
environment.globals["component"] = self.template_tag
3237

3338
@pass_context
34-
def template_tag(self, jinja_context: Context, dotted_path: str, *args, **kwargs) -> str:
39+
def template_tag(
40+
self, jinja_context: Context, dotted_path: str, *args, **kwargs
41+
) -> str:
3542
"""
3643
This method is used to embed an existing ReactPy component into your
3744
Jinja2 template.
@@ -46,9 +53,14 @@ def template_tag(self, jinja_context: Context, dotted_path: str, *args, **kwargs
4653
Returns:
4754
Whatever the components returns.
4855
"""
49-
django_context = RequestContext(jinja_context.parent['request'], autoescape=jinja_context.eval_ctx.autoescape)
56+
django_context = RequestContext(
57+
jinja_context.parent["request"],
58+
autoescape=jinja_context.eval_ctx.autoescape,
59+
)
5060
template_context = component(django_context, dotted_path, *args, **kwargs)
5161
#
5262
# TODO: can this be usefully cached?
5363
#
54-
return loader.render_to_string(self.DJT_TEMPLATE, template_context, jinja_context.parent['request'])
64+
return loader.render_to_string(
65+
DJT_TEMPLATE, template_context, jinja_context.parent["request"]
66+
)

0 commit comments

Comments
 (0)