Debian Codegraph @

django_jinja/views/generic/base.py

raw symbols SCIP
1 from ...base import get_match_extension
2
3
4 class Jinja2TemplateResponseMixin:
5 jinja2_template_extension = None
6
7 def get_template_names(self):
8 """
9 Return a list of template names to be used for the request.
10 This calls the super class's get_template_names and appends
11 the Jinja2 match extension is suffixed to the returned values.
12
13 If you specify jinja2_template_extension then that value will
14 be used. Otherwise it tries to detect the extension based on
15 values in settings.
16
17 If you would like to not have it append an extension, set
18 jinja2_template_extension to '' (empty string).
19 """
20 vals = super().get_template_names()
21
22 ext = self.jinja2_template_extension
23 if ext is None:
24 ext = get_match_extension(using=getattr(self, 'template_engine', None))
25
26 # Exit early if the user has specified an empty match extension
27 if not ext:
28 return vals
29
30 names = []
31 for val in vals:
32 if not val.endswith(ext):
33 val += ext
34 names.append(val)
35
36 return names