Ignore:
Timestamp:
10 Sep 2013, 14:59:40 (11 years ago)
Author:
uli
Message:

Enable shared header/footer partial templates.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.cas/trunk/waeup/cas/server.py

    r10605 r10607  
    176176
    177177def get_template(name):
     178    """Read template named `name`.
     179
     180    Templates are looked up in the local `templates` dir.
     181
     182    In the result any 'PART_HEADER' and 'PART_FOOTER' parts are
     183    replaced by the respective templates.
     184
     185    Returns the HTML template.
     186    """
    178187    path = os.path.join(template_dir, name)
    179188    if os.path.isfile(path):
    180         return open(path, 'r').read()
     189        html = open(path, 'r').read()
     190        html = html.replace(
     191            'PART_HEADER',
     192            open(os.path.join(template_dir, 'part_header.tpl'), 'r').read())
     193        html = html.replace(
     194            'PART_FOOTER',
     195            open(os.path.join(template_dir, 'part_footer.tpl'), 'r').read())
     196        return html
    181197    return None
    182198
     
    293309
    294310    def _get_template(self, name):
    295         path = os.path.join(template_dir, name)
    296         if os.path.isfile(path):
    297             return open(path, 'r').read()
    298         return None
     311        return get_template(name)
    299312
    300313    def login(self, req):
Note: See TracChangeset for help on using the changeset viewer.