New hybrid file format combining a Jinja template with Python code in a frontmatter
Project description
Jinjapy
New hybrid file format combining a Jinja template with Python code in a frontmatter
from jinja2 import Environment
import jinjapy
loader = jinjapy.register_package("my_package")
env = Environment(loader=loader)
# execute the module + render the template
# the module globals are used as the template context
template_output = jinjapy.execute_module(env, "my_package.module")
# module is available like any other import
import foo from my_package.module
my_package/module.jpy:
---
foo = "bar"
---
{{ foo }}
Specification
A jinjapy file contains 2 sections:
- A frontmatter with some Python code (enclosed by lines containg 3 dashes "---")
- A body containing some Jinja template code
Both are optional:
- If the frontmatter is missing, the file only contains a Jinja template
- If the frontmatter is left unclosed (the file starts with "---" on a single line followed by some python code), the file has no template
Editor support
A VS Code extension is available to add syntax highlighting for jinjapy files.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jinjapy-0.1.1.tar.gz.
File metadata
- Download URL: jinjapy-0.1.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6000086ef2994166f78045e0858def0f8fe1c5f8ee7a1ce56ca7eaa0c0181554
|
|
| MD5 |
cf8162d65a7b183bb010a69876cf9183
|
|
| BLAKE2b-256 |
6fd58de9d46d2d3c788d799c1a8e0c0fa46f1b228a14eac9ba869ec6d7aadda0
|
File details
Details for the file jinjapy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: jinjapy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86f29fa1e3e34655c2a019c8a5056b6a438a5787118a1f297a9260fda78188a5
|
|
| MD5 |
14330aa497d8207300cebdf1673d8182
|
|
| BLAKE2b-256 |
628c2c06fad4074b285af97e578d94cb1961885dd4b3026cc07f8134c91344ba
|