Skip to main content

Jinja-Frontmatter

Utilities to handle frontmatters in Jinja templates

Installation

pip install jinja-frontmatter

Remove frontmatter from templates

from jinja2 import Environment, PackageLoader
from jinja_frontmatter import RemoveFrontmatterLoader, get_template_frontmatter
import yaml

env = Environment(loader=RemoveFrontmatterLoader(PackageLoader(__name__, 'templates')))
frontmatter = get_template_frontmatter(env, "template.html") # frontmatter as text
frontmatter = get_template_frontmatter(env, "template.html", loads=yaml.safe_load) # frontmatter as yaml

Access YAML frontmatters in templates

from jinja2 import Environment, PackageLoader
from jinja_frontmatter import YAMLFrontmatterExtension

env = Environment(loader=PackageLoader(__name__, 'templates'))
env.add_extension(YAMLFrontmatterExtension)

In your template:

---
foo: bar
---
{{ frontmatter.foo }}

Metadata

Release files for jinja-frontmatter 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jinja-frontmatter 0.1.0
File Size Uploaded
jinja_frontmatter-0.1.0.tar.gz 2.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jinja-frontmatter 0.1.0
File Interpreter ABI Platform
jinja_frontmatter-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.4 kB

Release files / jinja_frontmatter-0.1.0.tar.gz

Download URL jinja_frontmatter-0.1.0.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
408ef4cf629faf37bcf9c870a1c24f1c174acffe5a51cdfec52ed09b1e3db838
BLAKE2b-256 checksum
How to use checksums
ffe3d3dc496dffa95c41a2d75a54ff1abe4240f490551d6b6d77d50a96144591
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-40-generic

Release files / jinja_frontmatter-0.1.0-py3-none-any.whl

Download URL jinja_frontmatter-0.1.0-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35d3ade0645c82ade4fd172274ddecfbda34a5ce80b91831001feeb8d04cd3f3
BLAKE2b-256 checksum
How to use checksums
693b584d8da6fdbc7b572ccef41bbb809fc931c4100c6927136f88bea6bce998
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-40-generic

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page