mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Refs #33476 -- Reformatted code with Black.
This commit is contained in:
committed by
Mariusz Felisiak
parent
f68fa8b45d
commit
9c19aff7c7
@@ -16,7 +16,7 @@ def get_default_renderer():
|
||||
|
||||
class BaseRenderer:
|
||||
def get_template(self, template_name):
|
||||
raise NotImplementedError('subclasses must implement get_template()')
|
||||
raise NotImplementedError("subclasses must implement get_template()")
|
||||
|
||||
def render(self, template_name, context, request=None):
|
||||
template = self.get_template(template_name)
|
||||
@@ -29,12 +29,14 @@ class EngineMixin:
|
||||
|
||||
@cached_property
|
||||
def engine(self):
|
||||
return self.backend({
|
||||
'APP_DIRS': True,
|
||||
'DIRS': [Path(__file__).parent / self.backend.app_dirname],
|
||||
'NAME': 'djangoforms',
|
||||
'OPTIONS': {},
|
||||
})
|
||||
return self.backend(
|
||||
{
|
||||
"APP_DIRS": True,
|
||||
"DIRS": [Path(__file__).parent / self.backend.app_dirname],
|
||||
"NAME": "djangoforms",
|
||||
"OPTIONS": {},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class DjangoTemplates(EngineMixin, BaseRenderer):
|
||||
@@ -42,6 +44,7 @@ class DjangoTemplates(EngineMixin, BaseRenderer):
|
||||
Load Django templates from the built-in widget templates in
|
||||
django/forms/templates and from apps' 'templates' directory.
|
||||
"""
|
||||
|
||||
backend = DjangoTemplates
|
||||
|
||||
|
||||
@@ -50,9 +53,11 @@ class Jinja2(EngineMixin, BaseRenderer):
|
||||
Load Jinja2 templates from the built-in widget templates in
|
||||
django/forms/jinja2 and from apps' 'jinja2' directory.
|
||||
"""
|
||||
|
||||
@cached_property
|
||||
def backend(self):
|
||||
from django.template.backends.jinja2 import Jinja2
|
||||
|
||||
return Jinja2
|
||||
|
||||
|
||||
@@ -61,5 +66,6 @@ class TemplatesSetting(BaseRenderer):
|
||||
Load templates using template.loader.get_template() which is configured
|
||||
based on settings.TEMPLATES.
|
||||
"""
|
||||
|
||||
def get_template(self, template_name):
|
||||
return get_template(template_name)
|
||||
|
||||
Reference in New Issue
Block a user