-
-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Description
https://code-maven.com/minimal-example-generating-html-with-python-jinja
Thanks for your amazing jinja example.
One suggestion: The first example could be simlified a bit with pathlib
from jinja2 import Environment, FileSystemLoader
from pathlib import Path
root = Path.cwd()
templates_dir = root /'templates'
env = Environment( loader = FileSystemLoader(templates_dir) )
template = env.get_template('index.html')
filename = root / "rendered_index.html"
with open(filename, 'w') as fh:
fh.write(template.render(
h1 = "Hello Jinja2",
show_one = True,
show_two = False,
names = ["Foo", "Bar", "Qux"],
))Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels