Jinja2: Difference between revisions
Jump to navigation
Jump to search
Line 26: | Line 26: | ||
.get_template('my-template.yaml.j2') \ | .get_template('my-template.yaml.j2') \ | ||
.render(variable_1='some value', variable2='some other value') | .render(variable_1='some value', variable2='some other value') | ||
</syntaxhighlight> | |||
=Templating Language= | |||
==Variable== | |||
<syntaxhighlight lang='jinja2'> | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 06:11, 2 March 2022
External
- https://medium.com/knoldus/jinja2-template-the-modern-design-friendly-templating-engine-a9218fec96e5
- https://jinja.palletsprojects.com/en/2.11.x/
- https://pypi.org/project/Jinja2/
Internal
Overview
Programming Model
Find out what the latest version is from https://pypi.org/project/Jinja2/
Then add this to your requirements.txt
jinja2 == 3.0.3
Once the virtual environment is updated, use it as such:
from pathlib import Path
from jinja2 import Environment, FileSystemLoader
template_dir = Path('...')
yaml = Environment(loader=FileSystemLoader(template_dir))\
.get_template('my-template.yaml.j2') \
.render(variable_1='some value', variable2='some other value')