lektor-jinja-content
This is a Lektor plugin that allows you to render Jinja2 inside your content fields that are string-like. For example, this means that inside your content fields that are of type string or Markdown, you can write Jinja logic, and access Lektor's Template Context, and has access to all normal Jinja filters, including those provided by other plugins. In a Markdown field (or other field that is rendered - like rst), the Jinja is processed first, then the formatting processor.
You can set and use Jinja variables, but they will only have meaning within their field that is being rendered.
With this plugin, you'll have to make sure the content that is rendered is valid Jinja. Jinja syntax erros will throw an exception. Don't forget about the handy {% raw %} {% endraw %} tags if you want content that is not valid Jinja.
N.B. Using this plugin is rendering many more items with Jinja, and your build process will slow down as a result. As an early benchmark and anecdote, my small website's build time rose from 4.89s to 5.39s even while I actually had no Jinja-Content that needed rendering. I plan on adding the ability to configure this plugin later so that you don't have to run everything through Jinja if you don't want to.
Examples
Querying context: {{ site.get('/').title }} or {{ this.path }}
Logic:
{% set meaning_of_life, meaning_of_universe = this.life, this.universe %}
{% if meaning_of_life == meaning_of_universe == 42 %}
{% set meaning_of_it_all = meaning_of_life %}
{% else %}
{% set meaning_of_it_all = 'Undefined' %}
{% endif %}
{{ meaning_of_it_all }}
Jinja in Markdown:
[link text]({{ this|url }})
Jinja in reStructuredText:
`link text <{{ this|url }}>`_
Try running the test site for more examples.
Possible future of this plugin.
This Plugin opens the door to some pretty powerful and pretty funky functionality. Here's some food for though:
- Currently every every string-like field in
_dataand_blocksis processed, even things like_slugand_template. Can these other things be used? - Some people want to be able to include markdown in content files / declarations. This plugin might pave the way toward that with includes and extends.
- Could we Jinjaify static files?
- Databags?
- What about modularity?
Metadata
Release files for lektor-jinja-content 0.4.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lektor-jinja-content-0.4.4.tar.gz | 5.3 kB | Without provenance | Details for lektor-jinja-content-0.4.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lektor_jinja_content-0.4.4-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for lektor_jinja_content-0.4.4-py2.py3-none-any.whl |
Total release size: 10.5 kB
Release files / lektor-jinja-content-0.4.4.tar.gz
| Download URL | lektor-jinja-content-0.4.4.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fda5a1060062d9c1cad9a99be1aee0a5f87279a90712c441a09db6238daad558
|
|
BLAKE2b-256 checksum How to use checksums |
b5a91a2ed0b909bf6483f44e5386a981af6984f1f55f9fcff17824596b5fd7dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.4
|
Release files / lektor_jinja_content-0.4.4-py2.py3-none-any.whl
| Download URL | lektor_jinja_content-0.4.4-py2.py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
896d751903aad79f829820a7d4f658d59ef1826856f2318f6839fcad475d4c29
|
|
BLAKE2b-256 checksum How to use checksums |
9dd26af0850c83d74ea3c93c0de5b6ef0988359bea513b165f3fc78f477e7e05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.4
|
Security for lektor-jinja-content 0.4.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.