All posts by admin

Compiling Cheetah templates in code

In the application I’m working on we’re using Cheetah as the template infrastructure and I’ve been working with compiled templates built from the command line. A colleague suggested compiling them dynamically

source = Cheetah.Compiler.Compiler(file=config.templatePath(t), moduleName=os.path.splitext(outfile)[0]).moduleDef()
f = open(outpath + outfile, “w+t”)
f.write(source)
f.close()