This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
2011-09-20 09:36:41 +02:00
|
|
|
|
|
|
|
from mako.lookup import TemplateLookup
|
|
|
|
from mako.template import Template
|
|
|
|
|
2014-10-10 15:50:13 +02:00
|
|
|
from mandaye import config
|
2011-09-20 09:36:41 +02:00
|
|
|
|
2014-10-10 15:50:13 +02:00
|
|
|
templates_directories = config.templates_directories + [config.template_directory]
|
2014-08-27 15:34:11 +02:00
|
|
|
mylookup = TemplateLookup(directories=templates_directories,
|
2011-09-20 09:36:41 +02:00
|
|
|
input_encoding='utf-8')
|
|
|
|
|
2014-04-07 16:40:43 +02:00
|
|
|
def serve_template(templatename, encoding='utf-8', **kwargs):
|
2011-09-20 09:36:41 +02:00
|
|
|
""" serve a template
|
|
|
|
"""
|
2014-08-29 19:16:14 +02:00
|
|
|
kwargs.update(config.template_vars)
|
2011-09-20 09:36:41 +02:00
|
|
|
mytemplate = mylookup.get_template(templatename)
|
2013-10-23 17:50:54 +02:00
|
|
|
return mytemplate.render_unicode(static_url=config.static_url,
|
2014-08-29 19:16:14 +02:00
|
|
|
**kwargs).encode(encoding, 'replace')
|