From bc96c508249061a2d92ded39bd07ca1382ba7377 Mon Sep 17 00:00:00 2001 From: "Prof. Dr. Matthias Jung DL9MJ" Date: Mon, 2 Jun 2025 20:43:27 +0200 Subject: [PATCH] refactor: added template for html-sites --- src/build.py | 12 ++---------- templates/html/html.html | 8 ++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 templates/html/html.html diff --git a/src/build.py b/src/build.py index d2ef6fc..12a3c56 100644 --- a/src/build.py +++ b/src/build.py @@ -221,18 +221,10 @@ class Build: def __build_html_page(self, contents, page): for content in contents: + template = self.env.get_template("html.html") if content["url_part"] == page: - - if content["sidebar"] is None: - result = content["content"] - else: - result = '
\n' - result += f'
{content["content"]}
\n' - result += f'
{content["sidebar"]}
\n' - result += '
\n' - + result = template.render({"content": content}) with open(f"build/{page}.html", "w") as file: - result = self.__build_page(result) file.write(result) diff --git a/templates/html/html.html b/templates/html/html.html new file mode 100644 index 0000000..c11e029 --- /dev/null +++ b/templates/html/html.html @@ -0,0 +1,8 @@ +{% if content["sidebar"] == None %} +{{ content["content"] }} +{% else %} +
+
{{ content["content"] }}
+
{{ content["sidebar"] }}
+
+{% endif %} \ No newline at end of file