MCPcopy
hub / github.com/django/django / render_to_string

Method render_to_string

django/template/engine.py:203–217  ·  view source on GitHub ↗

Render the template specified by template_name with the given context. For use in Django's test suite.

(self, template_name, context=None)

Source from the content-addressed store, hash-verified

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 """

Callers 15

test_extend_errorMethod · 0.95
test_include_errorMethod · 0.95
test_mixing_loopMethod · 0.95
test_autoescape_offMethod · 0.95
test_include_cacheMethod · 0.95
test_includeMethod · 0.95
test_include_stateMethod · 0.95
renderFunction · 0.80
send_mailMethod · 0.80
render_to_kmlFunction · 0.80
render_to_kmzFunction · 0.80

Calls 4

select_templateMethod · 0.95
get_templateMethod · 0.95
ContextClass · 0.85
renderMethod · 0.45

Tested by 15

test_extend_errorMethod · 0.76
test_include_errorMethod · 0.76
test_mixing_loopMethod · 0.76
test_autoescape_offMethod · 0.76
test_include_cacheMethod · 0.76
test_includeMethod · 0.76
test_include_stateMethod · 0.76
test_basic_contextMethod · 0.64
test_cycle10Method · 0.64
test_cycle11Method · 0.64
test_cycle12Method · 0.64