Created
May 4, 2021 15:09
-
-
Save greencoder/7906ec8e27f940db42c5eb362c1a1708 to your computer and use it in GitHub Desktop.
Jinja2 Setup Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arrow | |
import jinja2 | |
# Set up the template engine | |
template_loader = jinja2.FileSystemLoader('./templates') | |
template_env = jinja2.Environment(loader=template_loader) | |
template_env.filters['fmt_date'] = lambda v: arrow.get(v, fmt).format(fmt) | |
# Write the file | |
template = template_env.get_template('template.html') | |
html = template.render(data={}) | |
pathlib.Path('index.html').write_text(html) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment