From ea21ec6193020009345866efe7145a8d3b8f2449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Mon, 8 Jul 2024 12:03:35 +0200 Subject: [PATCH] Add Jinja2 as default template engine --- jssg/models.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/jssg/models.py b/jssg/models.py index fe39c09..f27d1b3 100644 --- a/jssg/models.py +++ b/jssg/models.py @@ -91,16 +91,7 @@ def convert_case(match_obj): # extras=["fenced-code-blocks", "tables"], # ) - if "template_engine" in self.metadata.keys() and self.metadata["template_engine"] == "jinja2" : - return engines["jinja2"].from_string(self.content).render( - { - "posts": sorted( - Post.load_glob(), key=lambda p: p.timestamp, reverse=True - ), - "data":self.data - } - ) - else : + if "template_engine" in self.metadata.keys() and self.metadata["template_engine"] == "django" : return Template(self.content).render( Context( { @@ -111,6 +102,15 @@ def convert_case(match_obj): } ) ) + else : + return engines["jinja2"].from_string(self.content).render( + { + "posts": sorted( + Post.load_glob(), key=lambda p: p.timestamp, reverse=True + ), + "data":self.data + } + ) @classmethod def load(cls, path: Path) -> "Document":