You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often write blog posts that contain jinja-templating, mostly in code-sections.
The plugin will then try to parse this content , which it should not do. So I need to have a way to tell the plugin not to parse the code or post.
A simple way is to add a special string (e.g. PELICAN_NO_JINJA) into the post-content. If the plugin finds the special string, it does not parse the post at all. Here's a small patch:
diff --git a/pelican/plugins/jinja2content/jinja2content.py b/pelican/plugins/jinja2content/jinja2content.py
index 95b2064..db0c620 100644
--- a/pelican/plugins/jinja2content/jinja2content.py
+++ b/pelican/plugins/jinja2content/jinja2content.py
@@ -47,7 +47,8 @@ class JinjaContentMixin:
def read(self, source_path):
with pelican_open(source_path) as text:
- text = self.env.from_string(text).render()
+ if "<!-- PELICAN_NO_JINJA -->" not in text:
+ text = self.env.from_string(text).render()
with NamedTemporaryFile(delete=False) as f:
f.write(text.encode())
A better way would probably to use this special string as a start and end marker where the text in between would not be parsed.
The text was updated successfully, but these errors were encountered:
I often write blog posts that contain jinja-templating, mostly in
code
-sections.The plugin will then try to parse this content , which it should not do. So I need to have a way to tell the plugin not to parse the code or post.
A simple way is to add a special string (e.g.
PELICAN_NO_JINJA
) into the post-content. If the plugin finds the special string, it does not parse the post at all. Here's a small patch:A better way would probably to use this special string as a start and end marker where the text in between would not be parsed.
The text was updated successfully, but these errors were encountered: