From ddedd35c41f5c2831458eec13e6eb9a5a7aa23a6 Mon Sep 17 00:00:00 2001 From: webrian Date: Mon, 27 Nov 2023 08:32:42 +0100 Subject: [PATCH] Fix write courses script in case there is no upcoming cours --- scripts/template.html | 8 ++++++++ scripts/write-courses.py | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/template.html b/scripts/template.html index 48ba8b8..a642800 100644 --- a/scripts/template.html +++ b/scripts/template.html @@ -1,3 +1,4 @@ +{% if data|length >= 1 %} @@ -10,3 +11,10 @@ {% endfor %}
+{% else %} + {% if lang == "de" %} + Keine bevorstehenden Veranstaltungen oder Kurse eingetragen + {% else %} + Aucun événement ou cours à venir + {% endif %} +{% endif %} diff --git a/scripts/write-courses.py b/scripts/write-courses.py index 1cd5487..b5832c4 100755 --- a/scripts/write-courses.py +++ b/scripts/write-courses.py @@ -12,7 +12,9 @@ def run(): environment = Environment(loader=FileSystemLoader("./")) for lang in ( "de", "fr" ): + # Define the variables data = [] + header = ("", "", "") # Get the jinia template to render HTML template = environment.get_template(f"template.html") @@ -49,7 +51,8 @@ def run(): # Render the template with the data content = template.render( header=header, - data=data + data=data, + lang=lang ) # Open the output file to write the rendered template