Compare commits
No commits in common. "jinjaneu" and "main" have entirely different histories.
1 changed files with 6 additions and 20 deletions
|
@ -1,26 +1,12 @@
|
||||||
import jinja2
|
from staticjinja import Site
|
||||||
from datetime import datetime as dt
|
from datetime import datetime as dt
|
||||||
import pathlib
|
|
||||||
|
|
||||||
date_str = dt.now().strftime("%Y-%m-%d")
|
|
||||||
output_path = pathlib.Path("out")
|
|
||||||
input_path = pathlib.Path("templates")
|
|
||||||
|
|
||||||
jenv = jinja2.Environment(
|
|
||||||
loader=jinja2.FileSystemLoader(input_path),
|
|
||||||
autoescape=True, trim_blocks=True, lstrip_blocks=True,
|
|
||||||
keep_trailing_newline=False)
|
|
||||||
|
|
||||||
def render_template(template_name, output_name, **kwargs):
|
|
||||||
template = jenv.get_template(template_name)
|
|
||||||
with open(output_path / output_name, "w") as out_file:
|
|
||||||
out_file.write(template.render(**kwargs))
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
render_template("blog.html", "blog.html", date=date_str)
|
site = Site.make_site(env_globals={
|
||||||
render_template("faq.html", "faq.html", date=date_str)
|
'date': dt.now().strftime("%Y-%m-%d")
|
||||||
render_template("index.html", "index.html", date=date_str)
|
})
|
||||||
render_template("licenses.html", "licenses.html", date=date_str)
|
# enable automatic reloading
|
||||||
render_template("links.html", "links.html", date=date_str)
|
site.render(use_reloader=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue