Given a list of template names, return the first that can be loaded.
(self, template_name_list)
| 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)) |
no test coverage detected