import jinja2 from datetime import datetime as dt import pathlib date_str = dt.now().strftime("%Y-%m-%d") output_path = pathlib.Path("out") input_path = pathlib.Path("templates") jenv = jinja2.Environment( loader=jinja2.FileSystemLoader(input_path), autoescape=True, trim_blocks=True, lstrip_blocks=True, keep_trailing_newline=False) def render_template(template_name, output_name, **kwargs): template = jenv.get_template(template_name) with open(output_path / output_name, "w") as out_file: out_file.write(template.render(**kwargs)) if __name__ == "__main__": render_template("blog.html", "blog.html", date=date_str) render_template("faq.html", "faq.html", date=date_str) render_template("index.html", "index.html", date=date_str) render_template("licenses.html", "licenses.html", date=date_str) render_template("links.html", "links.html", date=date_str)