Jinja2: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 9: Line 9:


=Overview=
=Overview=
 
=Programming Model=
Find out what the latest version is from https://pypi.org/project/Jinja2/
Find out what the latest version is from https://pypi.org/project/Jinja2/


Line 15: Line 15:
<syntaxhighlight lang='text'>
<syntaxhighlight lang='text'>
jinja2 == 3.0.3
jinja2 == 3.0.3
</syntaxhighlight>
Once the virtual environment is updated, use it as such:
<syntaxhighlight lang='py'>
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')
</syntaxhighlight>
</syntaxhighlight>

Revision as of 06:03, 2 March 2022

External

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')