MCPcopy
hub / github.com/django/django / select_template

Method select_template

django/template/engine.py:219–234  ·  view source on GitHub ↗

Given a list of template names, return the first that can be loaded.

(self, template_name_list)

Source from the content-addressed store, hash-verified

217 return t.render(Context(context, autoescape=self.autoescape))
218
219 def select_template(self, template_name_list):
220 """
221 Given a list of template names, return the first that can be loaded.
222 """
223 if not template_name_list:
224 raise TemplateDoesNotExist("No template names provided")
225 not_found = []
226 for template_name in template_name_list:
227 try:
228 return self.get_template(template_name)
229 except TemplateDoesNotExist as exc:
230 if exc.args[0] not in not_found:
231 not_found.append(exc.args[0])
232 continue
233 # If we get here, none of the templates could be loaded
234 raise TemplateDoesNotExist(", ".join(not_found))

Callers 6

render_to_stringMethod · 0.95
render_flatpageFunction · 0.80
renderMethod · 0.80
directory_indexFunction · 0.80
renderMethod · 0.80
renderMethod · 0.80

Calls 4

get_templateMethod · 0.95
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected