Hi.
I have the following very basic Python script that uses a Jinja template file "scrap.j2" and instead of using a YAML file, I feed variables in the python script directly using a string.
I am unable to successfully load the Jinja template. I get no error, but the result is an empty string.
Here is my Python script
#! /usr/bin/python3
from jinja2 import Environment, FileSystemLoader
#load Jinja Template
env=Environment(loader=FileSystemLoader("./"))
my_template = env.get_template("scrap.j2")
#feed variables to the template
result = my_template.render({"user": "lab"})
print(result)
Here is my Jinja file scrap.j2
hello {{ user }}
I expect the script to print "hello lab", but instead it's printing an empty string.
Kindly let me know what I'm doing wrong here.
Many thanks,
Deepak
Juniper Business Use Only