From 93ba63e11d5ce8e0a032ba27afa29c130c34eb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=BCller=20=28ChaoticByte=29?= Date: Sun, 17 Mar 2024 11:07:00 +0100 Subject: [PATCH] Provide datetime.now and datetime.strftime to the content template --- generate.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/generate.py b/generate.py index eaa2c42..3ab0691 100755 --- a/generate.py +++ b/generate.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 from argparse import ArgumentParser +from datetime import datetime from pathlib import Path from jinja2 import Template @@ -98,6 +99,10 @@ if __name__ == "__main__": # template content with args.template.open("r") as f: content_template = Template(f.read()) + # additional functions + content_template.globals['now'] = datetime.now + content_template.globals['strftime'] = datetime.strftime + # render content = content_template.render(data) # template out complete html document result = BASE_TEMPLATE.render(lang=data["lang"], title=data["title"], paper_css=PAPER_CSS, css=css, content=content)