YamlLoader for jinja2
Project description
jinja2loader
YamlLoader is a template loader for jinja2 template framework. It loads templates from yaml-files. Useful when you need to store many small templates in one file.
Install
pip install j2tools
Usage:
# templates.yaml
home:
welcome: |
Welcome, {{username}}!
goodbye: |
Goodbye, {{username}}!
# main.py
from jinja2 import Environment
from jinja2yaml import YamlLoader
jinja = Environment(loader=YamlLoader('templates.yaml'))
username = 'John Doe'
template1 = jinja.get_template('home/welcome')
rendered1 = template1.render(username=username)
print(rendered1) # Welcome, John Doe!
template2 = jinja.get_template('home/goodbye')
rendered2 = template2.render(username=username)
print(rendered2) # Goodbye, John Doe!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jinja2yaml-0.1.4.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for jinja2yaml-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87466cf5d9f6ac36343bec513ce3ac6b13b7ce17517b02bdfab3f2b9b8a86459 |
|
MD5 | 57db4c44ada430d65be01f90504c0278 |
|
BLAKE2b-256 | 782fffebd450a67e89b1e4e44fceee5c27ab74e2612fc3a7f99621ec1bbfd1a9 |