diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2005-09-29 13:26:49 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2005-09-29 13:26:49 +0000 |
| commit | 152d4373053b3148a401bf8a320dfa76b60cca86 (patch) | |
| tree | 3a219d0b351d3c923fb18bbf93f16c070d8ae2a6 | |
| parent | 808b3f4b9180dbcd4a8a84323b44a58b9bcdbd4a (diff) | |
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
| -rw-r--r-- | django/core/template_loader.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/django/core/template_loader.py b/django/core/template_loader.py index 1d973df687..7c26cf0faa 100644 --- a/django/core/template_loader.py +++ b/django/core/template_loader.py @@ -22,10 +22,15 @@ def get_template_from_string(source): def render_to_string(template_name, dictionary=None, context_instance=None): """ 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 {} - t = get_template(template_name) + if isinstance(template_name, (list, tuple)): + t = select_template(template_name) + else: + t = get_template(template_name) if context_instance: context_instance.update(dictionary) else: |
