lib/template.py
changeset 26 9d3beac1b196
parent 21 b05979822dee
child 32 be954df4f0e8
equal deleted inserted replaced
25:8f143b1ce0d1 26:9d3beac1b196
     7 from mako.template import Template
     7 from mako.template import Template
     8 from mako.lookup import TemplateLookup
     8 from mako.lookup import TemplateLookup
     9 
     9 
    10 # for http.ResponseError
    10 # for http.ResponseError
    11 import http
    11 import http
       
    12 
       
    13 import helpers
    12 
    14 
    13 # path to template files
    15 # path to template files
    14 TEMPLATE_DIR = "templates"
    16 TEMPLATE_DIR = "templates"
    15 
    17 
    16 # path to cached templates
    18 # path to cached templates
    57     """
    59     """
    58         Render the given template, returning the output as a unicode string, or raising a TemplateError
    60         Render the given template, returning the output as a unicode string, or raising a TemplateError
    59     """
    61     """
    60 
    62 
    61     try :
    63     try :
    62         return tpl.render_unicode(**params)
    64         return tpl.render_unicode(
       
    65             # global helper stuff
       
    66             h           = helpers,
       
    67 
       
    68             # render-specific params
       
    69             **params
       
    70         )
    63     
    71     
    64     # a template may render other templates
    72     # a template may render other templates
    65     except TemplateError :
    73     except TemplateError :
    66         raise
    74         raise
    67 
    75