From 44ab2ed1b83081ccfc205da257eb77a54c20c1e4 Mon Sep 17 00:00:00 2001 From: ClmntBcqt <129279765+ClmntBcqt@users.noreply.github.com> Date: Mon, 8 Jul 2024 13:41:52 +0200 Subject: [PATCH] rename engine metadata to template_engine (#29) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * rename engine metadata to template_engine * Add Jinja2 as default template engine --------- Co-authored-by: Clément --- content/pages/a_page.md | 2 +- content/pages/another_page.md | 2 +- galae-content/pages/en-index.md | 3 ++- galae-content/pages/fr-index.md | 2 +- .../pages/generateur-enregistrements-dns.md | 2 +- galae-content/pages/temoignages-clients.md | 2 +- jssg/models.py | 23 ++++++++++--------- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/content/pages/a_page.md b/content/pages/a_page.md index d58ec84..19c7922 100644 --- a/content/pages/a_page.md +++ b/content/pages/a_page.md @@ -1,7 +1,7 @@ --- title Page1 slug page1 -engine jinja2 +template_engine jinja2 --- { diff --git a/content/pages/another_page.md b/content/pages/another_page.md index 0efd582..9e1c210 100644 --- a/content/pages/another_page.md +++ b/content/pages/another_page.md @@ -1,7 +1,7 @@ --- title Another page slug page2 -engine jinja2 +template_engine jinja2 --- { diff --git a/galae-content/pages/en-index.md b/galae-content/pages/en-index.md index 713af5e..0aa0457 100644 --- a/galae-content/pages/en-index.md +++ b/galae-content/pages/en-index.md @@ -1,10 +1,11 @@ --- METADATA (first) --- + title galae - ethical and free pay-per-use e-mail slug en-index description galae est un service e-mail éthique et libre facturé à l'usage. Toutes nos offres incluent des boîtes emails et domaines illimités hébergés en France. language French lang en -engine jinja2 +template_engine jinja2 page_header_h1 galae - the free, ethical, pay-per-use e-mail service page_header_h2 Standard, interoperable e-mails and a service entirely based on self-hosting ready technologies diff --git a/galae-content/pages/fr-index.md b/galae-content/pages/fr-index.md index 361ef38..a0313e9 100644 --- a/galae-content/pages/fr-index.md +++ b/galae-content/pages/fr-index.md @@ -4,7 +4,7 @@ slug fr-index description galae est un service e-mail éthique et libre facturé à l'usage. Toutes nos offres incluent des boîtes emails et domaines illimités hébergés en France. language French lang fr -engine jinja2 +template_engine jinja2 page_header_h1 le service e-mail éthique et libre facturé à l'usage page_header_h2 pour des e-mails standards et interopérables et un service intégralement basé sur des technologies auto-hébergeables diff --git a/galae-content/pages/generateur-enregistrements-dns.md b/galae-content/pages/generateur-enregistrements-dns.md index 5e3c5b4..a776c70 100644 --- a/galae-content/pages/generateur-enregistrements-dns.md +++ b/galae-content/pages/generateur-enregistrements-dns.md @@ -4,7 +4,7 @@ description galae est un service e-mail éthique et libre facturé à l'usag slug generateur-enregistrements-dns language French lang fr -engine jinja2 +template_engine jinja2 page_header_h1 Générez les enregistrements DNS de vos domaines diff --git a/galae-content/pages/temoignages-clients.md b/galae-content/pages/temoignages-clients.md index dd354da..3fa259d 100644 --- a/galae-content/pages/temoignages-clients.md +++ b/galae-content/pages/temoignages-clients.md @@ -2,7 +2,7 @@ title Temoignages clients slug temoignages-clients lang fr -engine jinja2 +template_engine jinja2 page_header_h1 Nos clients témoignent ... --- diff --git a/jssg/models.py b/jssg/models.py index a94f450..9498ed8 100644 --- a/jssg/models.py +++ b/jssg/models.py @@ -88,17 +88,9 @@ def content(self) -> str: # extras=["fenced-code-blocks", "tables"], # ) - if "engine" in self.metadata.keys() and self.metadata["engine"] == "jinja2" : - return engines["jinja2"].from_string(self.body).render( - { - "posts": sorted( - Post.load_glob(), key=lambda p: p.timestamp, reverse=True - ), - "data":self.data - } - ) - else : - return Template(self.body).render( + + if "template_engine" in self.metadata.keys() and self.metadata["template_engine"] == "django" : + return Template(self.content).render( Context( { "posts": sorted( @@ -108,6 +100,15 @@ def content(self) -> str: } ) ) + 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":