jnjrender

raw JSON →
1.0.11 verified Fri May 01 auth: no python

A utility to render Jinja2 templates with a YAML environment, allowing nested template rendering within rendered text. Current version 1.0.11, with no regular release cadence.

pip install jnjrender
error ModuleNotFoundError: No module named 'jnjrender'
cause The package is not installed or the environment is misconfigured.
fix
Run pip install jnjrender.
error TypeError: render_template() missing 1 required positional argument: 'environment'
cause The environment argument (a dict) is required and was omitted.
fix
Pass a dictionary as the second argument: render_template(template_string, {"key": "value"})
gotcha The environment parameter expects a dictionary, not a YAML string. If you have a YAML string, you must parse it yourself (e.g., using PyYAML).
fix Use yaml.safe_load(yaml_string) if you have a YAML file or string.
gotcha The library does not handle template inheritance or complex Jinja2 features beyond string interpolation. For advanced Jinja2 usage, consider using jinja2 directly.
fix Use the jinja2 library for full template support.
deprecated The package has not been updated since 2020 (version 1.0.11) and may have unpatched security issues with Jinja2 dependencies.
fix Consider migrating to jinja2's direct API or a more maintained alternative.

Basic rendering of a Jinja2 template string with a YAML-like environment dictionary.

import os
from jnjrender import render_template

template_string = "Hello {{ name }}!"
environment = {"name": "World"}
result = render_template(template_string, environment)
print(result)
# Output: Hello World!