Skip to content

Commit

Permalink
should fail on render fail try #2
Browse files Browse the repository at this point in the history
  • Loading branch information
TMaYaD committed Apr 30, 2009
1 parent 64a5e66 commit fd71e0d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
8 changes: 4 additions & 4 deletions git-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

TEMPLATE_DIR=templates
PUBLIC_DIR=public
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} || return fail
ofile=${PUBLIC_DIR}/${template/%mako/html}
python scripts/render.py ${template} > ${ofile} || exit -1
git add ${ofile}
done
4 changes: 4 additions & 0 deletions public/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/home/phoenix/rstmako
example mako template
this is a disaster

17 changes: 8 additions & 9 deletions scripts/render.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#!/usr/bin/python

import sys
import sys ,os

from mako.template import Template
from mako.lookup import TemplateLookup

mylookup = TemplateLookup(directories=['../templates'], module_directory='/tmp/mako_modules')
lookup = TemplateLookup(directories=['templates'], module_directory='/tmp/mako_modules')

def serve_template(templatename, **kwargs):
mytemplate = mylookup.get_template(templatename)
print mytemplate.render(**kwargs)

#here we read all the makos and render them
for arg in sys.argv:
serve_template(arg)
def main(argv):
for arg in argv:
print lookup.get_template(arg).render()

print os.getcwd()
if __name__ == "__main__":
main(sys.argv[1:])
2 changes: 1 addition & 1 deletion templates/test.mako
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
example mako template
re-re-render
this is a disaster

0 comments on commit fd71e0d

Please sign in to comment.