Changeset 664
- Timestamp:
- 09/22/05 09:57:05 (3 years ago)
- Files:
-
- django/trunk/django/core/extensions.py (modified) (1 diff)
- django/trunk/django/core/template_loader.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/extensions.py
r657 r664 6 6 from django.utils.httpwrappers import HttpResponse 7 7 8 def load_and_render(template_name, dictionary=None, context_instance=None): 9 dictionary = dictionary or {} 10 t = template_loader.get_template(template_name) 11 if context_instance: 12 context_instance.update(dictionary) 13 else: 14 context_instance = Context(dictionary) 15 return HttpResponse(t.render(context_instance)) 8 def render_to_response(*args, **kwargs): 9 return HttpResponse(template_loader.render_to_string(*args, **kwargs)) 10 11 load_and_render = render_to_response # For backwards compatibility. 16 12 17 13 class DjangoContext(Context): django/trunk/django/core/template_loader.py
r3 r664 19 19 """ 20 20 return template.Template(source) 21 22 def render_to_string(template_name, dictionary=None, context_instance=None): 23 """ 24 Loads the given template_name and renders it with the given dictionary as 25 context. Returns a string. 26 """ 27 dictionary = dictionary or {} 28 t = get_template(template_name) 29 if context_instance: 30 context_instance.update(dictionary) 31 else: 32 context_instance = template.Context(dictionary) 33 return t.render(context_instance) 21 34 22 35 def select_template(template_name_list): … … 120 133 """ 121 134 Signal that this template extends a parent template. 122 123 This tag may be used in two ways: ``{% extends "base" %}`` (with quotes) 135 136 This tag may be used in two ways: ``{% extends "base" %}`` (with quotes) 124 137 uses the literal value "base" as the name of the parent template to extend, 125 138 or ``{% entends variable %}`` uses the value of ``variable`` as the name
