Flutter-Bounty-Hunters / static_shock

A static site generator for Dart.
MIT License
58 stars 5 forks source link

Support Jinja templating within Markdown page content (Resolves #69) #107

Closed matthew-carroll closed 1 month ago

matthew-carroll commented 1 month ago

Support Jinja templating within Markdown page content (Resolves #69)

This PR alters the Static Shock pipeline to make it possible to run templating engines on content.

The pipeline now explicitly runs two different steps when it renders pages. First, the pipeline renders the content. Second, the pipeline renders the layout. In other words, content rendering and layout rendering are now explicitly different.

To facilitate the pipeline change, every PageRenderer now needs a method for rendering content and rendering layout. However, rendering layout is optional, because not every page uses an external layout, e.g., a Jinja page that fully defines its content in the page file.

After this PR, a Markdown page can include Jinja templating within its content by doing the following:

---
contentRenderers:
 - jinja
 - markdown
---

Package version: {{ pub.static_shock.version }}
matthew-carroll commented 1 month ago

FYI @angelosilvestre