Logical template selection

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""OLDNESS ------------------------------------------------------------------"""

if not ical:
    if p.template_prefix:
        t = template_loader.select_template(["places/%s_detail" % p.template_prefix, "places/detail"])
    else:
        t = template_loader.get_template('places/detail')
else:
    if p.template_prefix:
        t = template_loader.select_template(["places/%s_detail_ical" % p.template_prefix, "places/detail_ical"])
    else:
        t = template_loader.get_template('places/detail_ical')

"""NEWNESS (with added 'year' functionality ---------------------------------"""

tt = "places/%(prfx)sdetail%(year)s%(ical)s" # Template template
tv = {'prfx': p.template_prefix and "%s_" % p.template_prefix or '',
      'year': year and "_year" or '',
      'ical': ical and "_ical" or ''
      }

t = template_loader.select_template([tt % tv, 'places/detail'])

Comments

(Forgotten your password?)

You may use Markdown syntax here, but raw HTML will be removed.