Fixed #546 - render_to_string and render_to_response may now take lists of templates and use select_template instead of get_template. Thanks, hugo
git-svn-id: http://code.djangoproject.com/svn/django/trunk@717 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
808b3f4b91
commit
152d437305
|
@ -22,9 +22,14 @@ def get_template_from_string(source):
|
||||||
def render_to_string(template_name, dictionary=None, context_instance=None):
|
def render_to_string(template_name, dictionary=None, context_instance=None):
|
||||||
"""
|
"""
|
||||||
Loads the given template_name and renders it with the given dictionary as
|
Loads the given template_name and renders it with the given dictionary as
|
||||||
context. Returns a string.
|
context. The template_name may be a string to load a single template using
|
||||||
|
get_template, or it may be a tuple to use select_template to find one of
|
||||||
|
the templates in the list. Returns a string.
|
||||||
"""
|
"""
|
||||||
dictionary = dictionary or {}
|
dictionary = dictionary or {}
|
||||||
|
if isinstance(template_name, (list, tuple)):
|
||||||
|
t = select_template(template_name)
|
||||||
|
else:
|
||||||
t = get_template(template_name)
|
t = get_template(template_name)
|
||||||
if context_instance:
|
if context_instance:
|
||||||
context_instance.update(dictionary)
|
context_instance.update(dictionary)
|
||||||
|
|
Loading…
Reference in New Issue