pelican-plugins / jinja2content Goto Github PK
View Code? Open in Web Editor NEWUse Jinja2 template code within post content
Use Jinja2 template code within post content
When I run pip install pelican-jinja2content
I'm getting this error:
Could not find a version that satisfies the requirement pelican-jinja2content (from versions: )
No matching distribution found for pelican-jinja2content
Is this plugin publicly available?
Hello!
I am relatively new working with Pelican and was hoping it would be possible to setup both pelican-jinja2content and pelican-liquid-tags.
I had my site setup and rendering properly with only the liquid tags plugin. After following the install and configuration for jinja2contnet, pelican no longer recognizes liquid-plugins tags:
...
| Encountered unknown tag 'youtube'.
...
| Encountered unknown tag 'img'.
...
As soon as I remove "jinja2content" from pelicanconf.PLUGINS the generation works fine again.
So as explained in the readme in those templates that integrate jinja they are not available as this code is executed before to arrive to pelican.
Maybe it is possible to share some variables from pelican anyway?
I see that some variables are shared https://github.com/pelican-plugins/jinja2content/blob/main/pelican/plugins/jinja2content/jinja2content.py#L25 so they need to pass to jinja, maybe it is possible to create VARIABLES_FOR_JINJA
or something better.
The second step is to understand if it is possible to access to stuff like articles
in a way that is possible to do a loop of them in the home page, but I am not sure if a template to embed in the pages will achieve the same effect.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.