From cab9495315a525e12e61cdce78b855190917c734 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Sat, 16 Jul 2022 16:14:30 -0700 Subject: [PATCH] tmp --- lexipython/build.py | 17 ++++++++++++++--- lexipython/templates/page-skeleton.html | 24 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 lexipython/templates/page-skeleton.html diff --git a/lexipython/build.py b/lexipython/build.py index 9c15023..b18bad5 100644 --- a/lexipython/build.py +++ b/lexipython/build.py @@ -435,13 +435,24 @@ def build_all(path_prefix, lexicon_name): os.remove(pathto("article", filename)) print("Writing article pages...") l = len(articles) + from jinja2 import Environment, FileSystemLoader, select_autoescape + env = Environment(loader=FileSystemLoader('lexipython/templates'), autoescape=select_autoescape(['html'])) + template = env.get_template("page-skeleton.html") for idx in range(l): article = articles[idx] with open(pathto("article", article.title_filesafe + ".html"), "w", encoding="utf-8", newline='') as f: content = article.build_default_content() - article_html = page.format( - title = article.title, - content = content) + #article_html = page.format( + # title = article.title, + # content = content) + tmp = { + "lexicon": "lexicon", + "prompt": "prompt", + "title": "title", + "sidebar_rows": ["hello", "world"], + "contentblocks": ["

hello

", "world"], + } + article_html = template.render(**tmp) f.write(article_html) print(" Wrote " + article.title) diff --git a/lexipython/templates/page-skeleton.html b/lexipython/templates/page-skeleton.html new file mode 100644 index 0000000..ba6871c --- /dev/null +++ b/lexipython/templates/page-skeleton.html @@ -0,0 +1,24 @@ + + +{{title}} | {{lexicon}} + + + + + +
+ + +
{% for contentblock in contentblocks %} +
{{contentblock}}
{% endfor %} +
+
+ +