Mercurial > p > roundup > code
diff roundup/cgi/templating.py @ 4743:2d6959f1d2df
templating: proof of concept for Jinja2 support. Select 'jinja2'
template_engine in config and place .html templates into
html/jinja2
| author | anatoly techtonik <techtonik@gmail.com> |
|---|---|
| date | Thu, 17 Jan 2013 15:21:54 +0300 |
| parents | 9cc6d463cfbe |
| children | 955860a18e12 |
line wrap: on
line diff
--- a/roundup/cgi/templating.py Thu Jan 17 09:08:50 2013 +0300 +++ b/roundup/cgi/templating.py Thu Jan 17 15:21:54 2013 +0300 @@ -77,6 +77,10 @@ class LoaderBase: """ Base for engine-specific template Loader class.""" + def __init__(self, dir): + # loaders are given the template directory as a first argument + pass + def precompileTemplates(self): """ Go through a directory and precompile all the templates therein """ @@ -118,13 +122,17 @@ except NoTemplate, message: raise KeyError, message +class TemplateBase: + content_type = 'text/html' def get_loader(dir, engine_name): if engine_name == 'chameleon': - import engine_chameleon as engine + from engine_chameleon import Loader + elif engine_name == 'jinja2': + from engine_jinja2 import Jinja2Loader as Loader else: - import engine_zopetal as engine - return engine.Loader(dir) + from engine_zopetal import Loader + return Loader(dir) def context(client, template=None, classname=None, request=None): """Return the rendering context dictionary
