How about this?
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)
test.html
<h1>{{ foo }}</h1>
exit
<h1>Hello World!</h1>
If you use a framework such as Flask, you can do this at the bottom of the window before returning.
output_from_parsed_template = render_template('test.html', foo="Hello World!") with open("some_new_file.html", "wb") as f: f.write(output_from_parsed_template) return output_from_parsed_template
sberry Aug 08 2018-12-12T00: 00Z
source share