Skip to content

Commit

Permalink
revert back to temlates in lookup dir
Browse files Browse the repository at this point in the history
  • Loading branch information
TMaYaD committed Apr 30, 2009
1 parent 4157a46 commit 8159d1f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions git-hooks/pre-commit
@@ -1,7 +1,6 @@
#!/usr/bin/python

import sys
from glob import glob
import sys, os, fnmatch

from mako.template import Template
from mako.lookup import TemplateLookup
Expand All @@ -10,15 +9,20 @@ from mako.runtime import Context
template_dir = 'templates/'
public_dir = 'public/'

lookup = TemplateLookup(directories=[''], module_directory='/tmp/mako_modules')
lookup = TemplateLookup(directories=[template_dir], module_directory='/tmp/mako_modules')


def render(file):
ofile = public_dir + file.replace('mako','html')
buf = open(ofile,"w")
ctx = Context(buf)
lookup.get_template(file).render_context(ctx)
buf.close()

def main():
templates = glob(template_dir + "*.mako")
for template in templates:
ofile = template.replace(template_dir,public_dir,1).replace('mako','html')
buf = open(ofile,"w")
ctx = Context(buf)
print Template(filename=template, lookup=lookup).render_context(ctx)
for file in os.listdir(template_dir):
if fnmatch.fnmatch(file, '*.mako'):
render(file)

if __name__ == "__main__":
main()

0 comments on commit 8159d1f

Please sign in to comment.