Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: None  |  size: 0.59 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to call a method from Jinja template?
  2. #in here inputPath is jinja templates path
  3. for root, dirs, files in os.walk(inputPath):
  4.     for file in files:
  5.         fPath = root[len(inputPath) + 1:]
  6.         newPath = (fPath + "/" if fPath else '') + file
  7.         template = env.get_template(newPath)
  8.         oPath = os.path.join(outputPath, fPath)
  9.         try:
  10.             os.makedirs(oPath)
  11.         except:
  12.             pass
  13.         oPath=os.path.join(oPath,file)
  14.         with codecs.open(oPath,'w', "utf-8") as f:
  15.             f.write(template.render(projectname=projectName, mainxmlpath=mainXamlPath))