Ticket #13984: 0001-Added-template_name-as-a-return-value-of-django.temp.patch

File 0001-Added-template_name-as-a-return-value-of-django.temp.patch, 1.7 KB (added by Daniel Duan, 14 years ago)

Added template_name as an return value to select_template

  • django/template/loader.py

    From d8ae4c9144dd2fa074b1790928d2a31b1f966602 Mon Sep 17 00:00:00 2001
    From: DaNmarner <DaNmarner@gmail.com>
    Date: Fri, 23 Jul 2010 01:54:01 -0500
    Subject: [PATCH] Added template_name as a return value of django.template.select_template
    
    ---
     django/template/loader.py  |    2 +-
     docs/ref/templates/api.txt |    3 ++-
     2 files changed, 3 insertions(+), 2 deletions(-)
    
    diff --git a/django/template/loader.py b/django/template/loader.py
    index b807752..89f7aa5 100644
    a b def select_template(template_name_list):  
    189189    "Given a list of template names, returns the first that can be loaded."
    190190    for template_name in template_name_list:
    191191        try:
    192             return get_template(template_name)
     192            return get_template(template_name), template_name
    193193        except TemplateDoesNotExist:
    194194            continue
    195195    # If we get here, none of the templates could be loaded
  • docs/ref/templates/api.txt

    diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt
    index 3e26753..8dd47fb 100644
    a b Django has two ways to load templates from files:  
    528528.. function:: django.template.loader.select_template(template_name_list)
    529529
    530530    ``select_template`` is just like ``get_template``, except it takes a list
    531     of template names. Of the list, it returns the first template that exists.
     531    of template names. Of the list, it returns the first template that exists
     532    and its name.
    532533
    533534For example, if you call ``get_template('story_detail.html')`` and have the
    534535above :setting:`TEMPLATE_DIRS` setting, here are the files Django will look for,
Back to Top