Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename engine metadata to template_engine #29

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/pages/a_page.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title Page1
slug page1
engine jinja2
template_engine jinja2
---
{

Expand Down
2 changes: 1 addition & 1 deletion content/pages/another_page.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title Another page
slug page2
engine jinja2
template_engine jinja2
---
{

Expand Down
3 changes: 2 additions & 1 deletion galae-content/pages/en-index.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion galae-content/pages/fr-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion galae-content/pages/generateur-enregistrements-dns.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion galae-content/pages/temoignages-clients.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title Temoignages clients
slug temoignages-clients
lang fr
engine jinja2
template_engine jinja2

page_header_h1 Nos clients témoignent ...
---
Expand Down
23 changes: 12 additions & 11 deletions jssg/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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":
Expand Down
Loading