1
0
Fork 0
forked from reudnetz/website
website/render.py
2017-02-12 23:04:58 +01:00

17 lines
580 B
Python

#!/bin/python2
from jinja2 import Environment, FileSystemLoader
import os
import stat
os.chdir(os.path.dirname(os.path.abspath(__file__)))
env = Environment(loader=FileSystemLoader('templates'))
for template in filter(lambda x : x.endswith(".html"), env.list_templates()):
rendered = env.get_template(template).render(name=template).encode('utf-8')
os.chmod(template, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
with open(template, 'wb') as outfile:
outfile.write(rendered)
os.chmod(template, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)