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 }}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jinja_frontmatter-0.1.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jinja_frontmatter-0.1.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file jinja_frontmatter-0.1.0.tar.gz.

File metadata

  • Download URL: jinja_frontmatter-0.1.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-40-generic

File hashes

Hashes for jinja_frontmatter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 408ef4cf629faf37bcf9c870a1c24f1c174acffe5a51cdfec52ed09b1e3db838
MD5 5a3a19db392f4403bad650a857637500
BLAKE2b-256 ffe3d3dc496dffa95c41a2d75a54ff1abe4240f490551d6b6d77d50a96144591

See more details on using hashes here.

File details

Details for the file jinja_frontmatter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jinja_frontmatter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-40-generic

File hashes

Hashes for jinja_frontmatter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35d3ade0645c82ade4fd172274ddecfbda34a5ce80b91831001feeb8d04cd3f3
MD5 1885762d7e98d32de0b553bd4082d9d3
BLAKE2b-256 693b584d8da6fdbc7b572ccef41bbb809fc931c4100c6927136f88bea6bce998

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page