# Path: mako/ext/turbogears.py
# class TGPlugin:
# 
#     """TurboGears compatible Template Plugin."""
# 
#     def __init__(self, extra_vars_func=None, options=None, extension="mak"):
#         self.extra_vars_func = extra_vars_func
#         self.extension = extension
#         if not options:
#             options = {}
# 
#         # Pull the options out and initialize the lookup
#         lookup_options = {}
#         for k, v in options.items():
#             if k.startswith("mako."):
#                 lookup_options[k[5:]] = v
#             elif k in ["directories", "filesystem_checks", "module_directory"]:
#                 lookup_options[k] = v
#         self.lookup = TemplateLookup(**lookup_options)
# 
#         self.tmpl_options = {}
#         # transfer lookup args to template args, based on those available
#         # in getargspec
#         for kw in compat.inspect_getargspec(Template.__init__)[0]:
#             if kw in lookup_options:
#                 self.tmpl_options[kw] = lookup_options[kw]
# 
#     def load_template(self, templatename, template_string=None):
#         """Loads a template from a file or a string"""
#         if template_string is not None:
#             return Template(template_string, **self.tmpl_options)
#         # Translate TG dot notation to normal / template path
#         if "/" not in templatename:
#             templatename = (
#                 "/" + templatename.replace(".", "/") + "." + self.extension
#             )
# 
#         # Lookup template
#         return self.lookup.get_template(templatename)
# 
#     def render(
#         self, info, format="html", fragment=False, template=None  # noqa
#     ):
#         if isinstance(template, str):
#             template = self.load_template(template)
# 
#         # Load extra vars func if provided
#         if self.extra_vars_func:
#             info.update(self.extra_vars_func())
# 
#         return template.render(**info)
# 
# Path: mako/testing/config.py
# class Config(ReadsCfg):
# 
# Path: mako/testing/fixtures.py
# class TemplateTest:
#     def _file_template(self, filename, **kw):
#         filepath = self._file_path(filename)
#         return Template(
#             uri=filename,
#             filename=filepath,
#             module_directory=config.module_base,
#             **kw,
#         )
# 
#     def _file_path(self, filename):
#         name, ext = os.path.splitext(filename)
#         py3k_path = os.path.join(config.template_base, name + "_py3k" + ext)
#         if os.path.exists(py3k_path):
#             return py3k_path
# 
#         return os.path.join(config.template_base, filename)
# 
#     def _do_file_test(
#         self,
#         filename,
#         expected,
#         filters=None,
#         unicode_=True,
#         template_args=None,
#         **kw,
#     ):
#         t1 = self._file_template(filename, **kw)
#         self._do_test(
#             t1,
#             expected,
#             filters=filters,
#             unicode_=unicode_,
#             template_args=template_args,
#         )
# 
#     def _do_memory_test(
#         self,
#         source,
#         expected,
#         filters=None,
#         unicode_=True,
#         template_args=None,
#         **kw,
#     ):
#         t1 = Template(text=source, **kw)
#         self._do_test(
#             t1,
#             expected,
#             filters=filters,
#             unicode_=unicode_,
#             template_args=template_args,
#         )
# 
#     def _do_test(
#         self,
#         template,
#         expected,
#         filters=None,
#         template_args=None,
#         unicode_=True,
#     ):
#         if template_args is None:
#             template_args = {}
#         if unicode_:
#             output = template.render_unicode(**template_args)
#         else:
#             output = template.render(**template_args)
# 
#         if filters:
#             output = filters(output)
#         eq_(output, expected)
# 
# Path: mako/testing/helpers.py
# def result_lines(result):
#     return [
#         x.strip()
#         for x in re.split(r"\r?\n", re.sub(r" +", " ", result))
#         if x.strip() != ""
#     ]


from mako.ext.turbogears import TGPlugin
from mako.testing.config import config
from mako.testing.fixtures import TemplateTest
from mako.testing.helpers import result_lines
        assert result_lines(t.render()) == [
            "this is sub index",
            "this is include 2",
        ]

        assert (
            tl.load_template("/subdir/index.html").module_id
            == "_subdir_index_html"
        )

    def test_basic_dot(self):
        t = tl.load_template("index")
        assert result_lines(t.render()) == ["this is index"]

    def test_subdir_dot(self):
        t = tl.load_template("subdir.index")
        assert result_lines(t.render()) == [
            "this is sub index",
            "this is include 2",
        ]

        assert (
            tl.load_template("subdir.index").module_id == "_subdir_index_html"
        )

    def test_string(self):
        t = tl.load_template("foo", "hello world")
        assert t.render() == "hello world"

    def test_render(self):

# Path: mako/ext/turbogears.py
# class TGPlugin:
# 
#     """TurboGears compatible Template Plugin."""
# 
#     def __init__(self, extra_vars_func=None, options=None, extension="mak"):
#         self.extra_vars_func = extra_vars_func
#         self.extension = extension
#         if not options:
#             options = {}
# 
#         # Pull the options out and initialize the lookup
#         lookup_options = {}
#         for k, v in options.items():
#             if k.startswith("mako."):
#                 lookup_options[k[5:]] = v
#             elif k in ["directories", "filesystem_checks", "module_directory"]:
#                 lookup_options[k] = v
#         self.lookup = TemplateLookup(**lookup_options)
# 
#         self.tmpl_options = {}
#         # transfer lookup args to template args, based on those available
#         # in getargspec
#         for kw in compat.inspect_getargspec(Template.__init__)[0]:
#             if kw in lookup_options:
#                 self.tmpl_options[kw] = lookup_options[kw]
# 
#     def load_template(self, templatename, template_string=None):
#         """Loads a template from a file or a string"""
#         if template_string is not None:
#             return Template(template_string, **self.tmpl_options)
#         # Translate TG dot notation to normal / template path
#         if "/" not in templatename:
#             templatename = (
#                 "/" + templatename.replace(".", "/") + "." + self.extension
#             )
# 
#         # Lookup template
#         return self.lookup.get_template(templatename)
# 
#     def render(
#         self, info, format="html", fragment=False, template=None  # noqa
#     ):
#         if isinstance(template, str):
#             template = self.load_template(template)
# 
#         # Load extra vars func if provided
#         if self.extra_vars_func:
#             info.update(self.extra_vars_func())
# 
#         return template.render(**info)
# 
# Path: mako/testing/config.py
# class Config(ReadsCfg):
# 
# Path: mako/testing/fixtures.py
# class TemplateTest:
#     def _file_template(self, filename, **kw):
#         filepath = self._file_path(filename)
#         return Template(
#             uri=filename,
#             filename=filepath,
#             module_directory=config.module_base,
#             **kw,
#         )
# 
#     def _file_path(self, filename):
#         name, ext = os.path.splitext(filename)
#         py3k_path = os.path.join(config.template_base, name + "_py3k" + ext)
#         if os.path.exists(py3k_path):
#             return py3k_path
# 
#         return os.path.join(config.template_base, filename)
# 
#     def _do_file_test(
#         self,
#         filename,
#         expected,
#         filters=None,
#         unicode_=True,
#         template_args=None,
#         **kw,
#     ):
#         t1 = self._file_template(filename, **kw)
#         self._do_test(
#             t1,
#             expected,
#             filters=filters,
#             unicode_=unicode_,
#             template_args=template_args,
#         )
# 
#     def _do_memory_test(
#         self,
#         source,
#         expected,
#         filters=None,
#         unicode_=True,
#         template_args=None,
#         **kw,
#     ):
#         t1 = Template(text=source, **kw)
#         self._do_test(
#             t1,
#             expected,
#             filters=filters,
#             unicode_=unicode_,
#             template_args=template_args,
#         )
# 
#     def _do_test(
#         self,
#         template,
#         expected,
#         filters=None,
#         template_args=None,
#         unicode_=True,
#     ):
#         if template_args is None:
#             template_args = {}
#         if unicode_:
#             output = template.render_unicode(**template_args)
#         else:
#             output = template.render(**template_args)
# 
#         if filters:
#             output = filters(output)
#         eq_(output, expected)
# 
# Path: mako/testing/helpers.py
# def result_lines(result):
#     return [
#         x.strip()
#         for x in re.split(r"\r?\n", re.sub(r" +", " ", result))
#         if x.strip() != ""
#     ]


# Path: test/test_tgplugin.py
from mako.ext.turbogears import TGPlugin
from mako.testing.config import config
from mako.testing.fixtures import TemplateTest
from mako.testing.helpers import result_lines

        assert result_lines(t.render()) == [
            "this is sub index",
            "this is include 2",
        ]

        assert (
            tl.load_template("/subdir/index.html").module_id
            == "_subdir_index_html"
        )

    def test_basic_dot(self):
        t = tl.load_template("index")
        assert result_lines(t.render()) == ["this is index"]

    def test_subdir_dot(self):
        t = tl.load_template("subdir.index")
        assert result_lines(t.render()) == [
            "this is sub index",
            "this is include 2",
        ]

        assert (
            tl.load_template("subdir.index").module_id == "_subdir_index_html"
        )

    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")) == [