Skip to content

Commit

Permalink
Add Jinja2 as default template engine
Browse files Browse the repository at this point in the history
  • Loading branch information
Clément committed Jul 8, 2024
1 parent 9252c30 commit ea21ec6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions jssg/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -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":
Expand Down

0 comments on commit ea21ec6

Please sign in to comment.