def init(): config["url"] = urlparse.urljoin(bf.config.site.url, config["path"]) global template_lookup template_lookup = TemplateLookup( directories=[config["template_path"],"_templates"], input_encoding='utf-8', output_encoding='utf-8', encoding_errors='replace') base_template = template_lookup.get_template(config["base_template"]) template_lookup.put_template("blog_base_template",base_template)
def init(): config["url"] = urlparse.urljoin(bf.config.site.url, config["path"]) global template_lookup template_lookup = TemplateLookup( directories=[config["template_path"],"_templates"], input_encoding='utf-8', output_encoding='utf-8', encoding_errors='replace') base_template = template_lookup.get_template(config["base_template"]) template_lookup.put_template("blog_base_template",base_template)
def test_module_roundtrip(self): lookup = TemplateLookup() template = Template(""" <%inherit file="base.html"/> % for x in range(5): ${x} % endfor """, lookup=lookup) base = Template(""" This is base. ${self.body()} """, lookup=lookup) lookup.put_template("base.html", base) lookup.put_template("template.html", template) assert result_lines(template.render()) == [ "This is base.", "0", "1", "2", "3", "4" ] lookup = TemplateLookup() template = ModuleTemplate(template.module, lookup=lookup) base = ModuleTemplate(base.module, lookup=lookup) lookup.put_template("base.html", base) lookup.put_template("template.html", template) assert result_lines(template.render()) == [ "This is base.", "0", "1", "2", "3", "4" ]