If you use Cheetah, please support the project and register by clicking here:


4.4 Some trivia about .py template modules

We won't look inside .py template modules in this Guide except to note that they are very different from template definitions. The following template definition fragment:

The number is $Test.unittest.main.

compiles to this:

write("The number is ")  
write(filter(VFN(VFS(SL,"Test.unittest",1),"main",0)
write(".")

The Cheetah Developers' Guide looks at .py template modules in depth, and shows what the various directives compile to. But you are welcome to take a peek at some .py template modules yourself if you're curious about what Cheetah does under the hood. It's all regular Python code: writing strings and function calls to a file-like object.

Looking at a .py template module may also help you see why something doesn't work, by seeing what Cheetah thought you meant. It also helps discourage you from modifying the .py file yourself, because who wants to keep all those function calls and arguments straight? Let the computer do the drudgery work.

If you use Cheetah, please support the project and register by clicking here: