コード例 #1
0
ファイル: test_templates.py プロジェクト: pitchum/chameleon
    def test_pt_files(self):
        from ..zpt.template import PageTemplateFile

        class Literal(object):
            def __init__(self, s):
                self.s = s

            def __html__(self):
                return self.s

            def __str__(self):
                raise RuntimeError("%r is a literal." % self.s)

        from chameleon.loader import TemplateLoader

        loader = TemplateLoader(os.path.join(self.root, "inputs"))

        self.execute(
            ".pt",
            PageTemplateFile,
            literal=Literal("<div>Hello world!</div>"),
            content="<div>Hello world!</div>",
            message=Message(),
            load=loader.bind(PageTemplateFile),
        )
    def test_pt_files(self):
        from ..zpt.template import PageTemplateFile

        class Literal(object):
            def __init__(self, s):
                self.s = s

            def __html__(self):
                return self.s

            def __str__(self):
                raise RuntimeError("%r is a literal." % self.s)

        from chameleon.loader import TemplateLoader
        loader = TemplateLoader(os.path.join(self.root, "inputs"))

        self.execute(".pt",
                     PageTemplateFile,
                     literal=Literal("<div>Hello world!</div>"),
                     content="<div>Hello world!</div>",
                     message=Message(),
                     load=loader.bind(PageTemplateFile))
コード例 #3
0
 def loader(cls, path):
     loader = BaseLoader(search_path=path)
     load = loader.bind(cls)
     return load
コード例 #4
0
 def loader(cls, path):
     loader = BaseLoader(search_path=path)
     load = loader.bind(cls)
     return load