Answers for "jinja render template to file"

0

jinja render template to file

from jinja2 import Environment, FileSystemLoader

env = Environment(loader=FileSystemLoader('templates'))
template = env.get_template('test.html')

output_from_parsed_template = template.render(foo='Hello World!')
print(output_from_parsed_template)

# to save the results
with open("my_new_file.html", "w") as fh:
    fh.write(output_from_parsed_template)
Posted by: Guest on July-26-2020

Code answers related to "jinja render template to file"

Browse Popular Code Answers by Language