Skip to content

Instantly share code, notes, and snippets.

@whs
Created July 30, 2011 12:41
Show Gist options
  • Select an option

  • Save whs/1115484 to your computer and use it in GitHub Desktop.

Select an option

Save whs/1115484 to your computer and use it in GitHub Desktop.
WMC Renderer
from jinja2 import Environment, FileSystemLoader
from glob import glob
from os.path import basename
env = Environment(loader=FileSystemLoader('template'))
for i in glob("template/*.j.html"):
output = env.get_template(basename(i)).render()
open("output/" + basename(i).replace(".j.html", ".html"), "w").write(output)
@whs

whs commented Jul 30, 2011

Copy link
Copy Markdown
Author

Usage:

  • Make folders named template and output
  • Files ended with .j.html will be rendered to output/filename.html (file not ended with .j.html won't be rendered, so use it for your extend files)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment