Permalink
Browse files

Future-proofing. @amol- is a rockstar.

  • Loading branch information...
ralphbean committed Jun 15, 2012
1 parent 50d88cc commit bb006dfeb5107fb3fb1e43eb5128c205d1b3867b
Showing with 7 additions and 7 deletions.
  1. +1 −1 setup.py
  2. +6 −6 tw2/core/templating.py
@@ -43,7 +43,7 @@ def get_description(fname='README.rst'):
'PasteDeploy',
'speaklater',
'decorator',
'webhelpers',
'markupsafe',
]
if sys.version_info[0] == 2 and sys.version_info[1] <= 5:
@@ -3,7 +3,7 @@
from util import memoize
from webhelpers.html import literal
from markupsafe import Markup
# Just shorthand
SEP = os.path.sep
@@ -145,7 +145,7 @@ def get_render_callable(engine_name, displays_on, src, filename=None):
directories=[directory, SEP])
tmpl = mako.template.Template(**args)
return lambda kwargs: literal(tmpl.render(**kwargs))
return lambda kwargs: Markup(tmpl.render(**kwargs))
elif engine_name in ('genshi', 'genshi_abs'):
import genshi.template
@@ -159,25 +159,25 @@ def get_render_callable(engine_name, displays_on, src, filename=None):
])
tmpl = genshi.template.MarkupTemplate(**args)
return lambda kwargs: literal(
return lambda kwargs: Markup(
''.join(tmpl.generate(**kwargs).serialize('xhtml'))
)
elif engine_name == 'jinja':
import jinja2
tmpl = jinja2.Template(src)
tmpl.filename = filename
return lambda kwargs: literal(tmpl.render(**kwargs))
return lambda kwargs: Markup(tmpl.render(**kwargs))
elif engine_name == 'kajiki':
import kajiki
tmpl = kajiki.XMLTemplate(src, filename=filename)
return lambda kwargs: literal(tmpl(kwargs).render())
return lambda kwargs: Markup(tmpl(kwargs).render())
elif engine_name == 'chameleon':
import chameleon
tmpl = chameleon.PageTemplate(src, filename=filename)
return lambda kwargs: literal(tmpl.render(**kwargs).strip())
return lambda kwargs: Markup(tmpl.render(**kwargs).strip())
raise NotImplementedError("Unhandled engine")

0 comments on commit bb006df

Please sign in to comment.