Browse files

script entirely runs from python\n though it looses its change detection

  • Loading branch information...
1 parent 04fcdf2 commit 2315c2e42ccdf21806b7f26d31a198266ee2e039 @TMaYaD committed Apr 30, 2009
Showing with 12 additions and 15 deletions.
  1. +1 −9 git-hooks/pre-commit
  2. +11 −6 scripts/render.py
View
10 git-hooks/pre-commit
@@ -1,11 +1,3 @@
#!/bin/bash
-TEMPLATE_DIR='templates/'
-PUBLIC_DIR='public'
-
-for template in `git diff-index --name-only HEAD --relative=${TEMPLATE_DIR}`
-do
- ofile=${PUBLIC_DIR}/${template/%mako/html}
- python scripts/render.py ${template} > ${ofile} || exit -1
- git add ${ofile}
-done
+python scripts/render.py || exit -1
View
17 scripts/render.py
@@ -1,19 +1,24 @@
#!/usr/bin/python
-import sys ,os
+import sys
+from glob import glob
from mako.template import Template
from mako.lookup import TemplateLookup
+from mako.runtime import Context
template_dir = 'templates/'
public_dir = 'public/'
lookup = TemplateLookup(directories=[template_dir], module_directory='/tmp/mako_modules')
-def main(argv):
- for arg in argv:
- print lookup.get_template(arg).render()
+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)
-print os.getcwd()
if __name__ == "__main__":
- main(sys.argv[1:])
+ main()

0 comments on commit 2315c2e

Please sign in to comment.