Render the template specified by template_name with the given context. For use in Django's test suite.
(self, template_name, context=None)
| 201 | return partial |
| 202 | |
| 203 | def render_to_string(self, template_name, context=None): |
| 204 | """ |
| 205 | Render the template specified by template_name with the given context. |
| 206 | For use in Django's test suite. |
| 207 | """ |
| 208 | if isinstance(template_name, (list, tuple)): |
| 209 | t = self.select_template(template_name) |
| 210 | else: |
| 211 | t = self.get_template(template_name) |
| 212 | # Django < 1.8 accepted a Context in `context` even though that's |
| 213 | # unintended. Preserve this ability but don't rewrap `context`. |
| 214 | if isinstance(context, Context): |
| 215 | return t.render(context) |
| 216 | else: |
| 217 | return t.render(Context(context, autoescape=self.autoescape)) |
| 218 | |
| 219 | def select_template(self, template_name_list): |
| 220 | """ |