Commit a9e8e816 authored by berumuron's avatar berumuron
Browse files

Add cache for templates

parent 3702db82
......@@ -67,6 +67,9 @@ def build_page_from_filepath(filepath, configuration, basename=None, slug=None):
return Page(final_slug, page_file.read(), configuration=configuration)
templates_cache = {}
def write_content(content, output_path):
"""Write content (Article or Page) under output_path.
"""
......@@ -76,8 +79,12 @@ def write_content(content, output_path):
)
# Initialize the template defined within content
if os.path.exists(template_filepath):
if template_filepath in templates_cache:
template = templates_cache[template_filepath]
rendered_content = template.render(content.meta)
elif os.path.exists(template_filepath):
template = boopsy.Template(template_filepath)
templates_cache[template_filepath] = template
rendered_content = template.render(content.meta)
else:
rendered_content = content.content()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment