Skip to content

Releases: vd2org/jinja2yaml

v0.1.5

26 Feb 11:52
Compare
Choose a tag to compare

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 jinja2yaml

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!

v0.1.4

26 Feb 11:20
Compare
Choose a tag to compare

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!

v0.1.2

26 Feb 11:10
Compare
Choose a tag to compare

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!