Index: lib/mako/ext/turbogears.py =================================================================== --- lib/mako/ext/turbogears.py (revision 182) +++ lib/mako/ext/turbogears.py (working copy) @@ -1,5 +1,6 @@ import re from mako.lookup import TemplateLookup +from mako.template import Template class TGPlugin(object): """TurboGears compatible Template Plugin.""" @@ -19,20 +20,22 @@ tmpl_options[k] = v self.lookup = TemplateLookup(**tmpl_options) - def load_template(self, templatename): + def load_template(self, templatename, template_string=None): """Unused method for TG plug-in API compat""" - pass + if template_string is not None: + return Template(template_string) def render(self, info, format="html", fragment=False, template=None): - # Translate TG dot notation to normal / template path - if '/' and '.' not in template: - template = '/' + template.replace('.', '/') + '.' + self.extension + if isinstance(template, basestring): + # Translate TG dot notation to normal / template path + if '/' and '.' not in template: + template = '/' + template.replace('.', '/') + '.' + self.extension - # Load extra vars func if provided - if self.extra_vars_func: - info.update(self.extra_vars_func()) + # Load extra vars func if provided + if self.extra_vars_func: + info.update(self.extra_vars_func()) - # Lookup template - template = self.lookup.get_template(template) + # Lookup template + template = self.lookup.get_template(template) return template.render(**info)