コード例 #1
0
def test_template_manager():
    """
    Make sure the template manager basics work right.
    """
    template_dir = abspath("./tests/resources/templates/")
    templs = {"plain1": "PlainTemplate", "jinja1": "JinjaTemplate", "jinja2": "JinjaTemplate"}
    context = {"foo": "foo"}
    with tmpdir() as tmp:
        tplm = TemplateManager()
        for template in templs:
            kwargs = {}
            klasse = templs[template]
            if klasse == "JinjaTemplate":
                kwargs["context"] = context

            tplm.add_template(klasse, os.path.join(template_dir, template), **kwargs)

        tplm.render(tmp)