diff options
-rw-r--r-- | mako/ext/turbogears.py | 5 | ||||
-rw-r--r-- | test/test_tgplugin.py | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/mako/ext/turbogears.py b/mako/ext/turbogears.py index db71682..d1a6a90 100644 --- a/mako/ext/turbogears.py +++ b/mako/ext/turbogears.py @@ -4,7 +4,8 @@ # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php -import re, inspect +import inspect +from mako import compat from mako.lookup import TemplateLookup from mako.template import Template @@ -46,7 +47,7 @@ class TGPlugin(object): return self.lookup.get_template(templatename) def render(self, info, format="html", fragment=False, template=None): - if isinstance(template, str): + if isinstance(template, str if compat.py3k else basestring): template = self.load_template(template) # Load extra vars func if provided diff --git a/test/test_tgplugin.py b/test/test_tgplugin.py index 3ba5c75..9564c43 100644 --- a/test/test_tgplugin.py +++ b/test/test_tgplugin.py @@ -40,3 +40,11 @@ class TestTGPlugin(TemplateTest): def test_string(self): t = tl.load_template('foo', "hello world") assert t.render() == "hello world" + + def test_render(self): + assert result_lines(tl.render({}, template='/index.html')) == [ + "this is index" + ] + assert result_lines(tl.render({}, template=u'/index.html')) == [ + "this is index" + ] |