Rendering is changing data into something <variable> -------> into "value".
Parsing takes raw data or input and converts it a data structure, or structures that can be analyzed.
Jinja2 - 101 - Intro to Jinja2 template building
Widget Connector |
---|
url | https://vimeo.com/120005103 |
---|
|
...
|
|
---|
|
Code Block |
---|
| With Python: ( use extensively by Ansible)
>>> from jinja2 import Template
>>> template = Template('Hello {{ name }}!')
>>> template.render(name='John Doe')
'Hello John Doe!' |
|
|
Code Block |
---|
title | render jinja2 : option 1 |
---|
| def render_jinja2():
from jinja2 import Template
with open(r"C:\Users\jkriker\Documents\GitHub\JAUT_Training\Basic-python-with-Juniper\Napalm\config_unit.j2") as file_:
template = Template(file_.read())
print(template.render(unit_id='5', vlan_id=5, subnet="0.5"))
render_jinja2(template_name, list_variables)
|
|
|
|
|
|
|
|
|
|
|
|