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


4.3 ``cheetah fill''

You can compile and fill a large number of template definitions from the command line in one step using cheetah fill. This compiles the template in memory; it does not save the .py template module to disk. Instead it writes a finished output file, which has the extension .html by default. All the options to cheetah compile work the same way here, and there are also a couple additional options:

  --env : put the environment in the searchList
  --pickle FILE : unpickle FILE and put that object in the searchList

Because you can't provide a searchList on the command line, the templates must either contain or inherit all the variables it needs, or use the --env and --pickle options to provide additional variables.

Examples:

cheetah fill a.tmpl              : writes a.html
cheetah fill a.tmpl b.tmpl       : writes a.html and b.html
cheetah f --oext txt a           : writes a.txt (from a.tmpl)

Using --env may have security or reliability implications because the environment normally contains lots of variables you inherited rather than defining yourself. If any of these variables override any of yours (say a #def), you will get incorrect output, may reveal private information, and may get an exception due to the variable being an unexpected type (environmental variables are always strings). Your calling program may wish to clear out the environment before setting environmental variables for the template.

There are two other differences between ``cheetah compile'' and ``cheetah fill''. Cheetah doesn't create __init__.py files when creating directories in fill mode. Also, the source filenames don't have to be identifiers.

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