
Untitled
By: a guest on
Aug 10th, 2012 | syntax:
None | size: 0.59 KB | hits: 11 | expires: Never
How to call a method from Jinja template?
#in here inputPath is jinja templates path
for root, dirs, files in os.walk(inputPath):
for file in files:
fPath = root[len(inputPath) + 1:]
newPath = (fPath + "/" if fPath else '') + file
template = env.get_template(newPath)
oPath = os.path.join(outputPath, fPath)
try:
os.makedirs(oPath)
except:
pass
oPath=os.path.join(oPath,file)
with codecs.open(oPath,'w', "utf-8") as f:
f.write(template.render(projectname=projectName, mainxmlpath=mainXamlPath))