For a basic introduction to Velocity, visit http://jakarta.apache.org/velocity.
Velocity is a Java template engine. It's older than Cheetah, has a larger user base, and has better examples and docs at the moment. Cheetah, however, has a number of advantages over Velocity:
VelocityContext context1 = new VelocityContext(); context1.put("name","Velocity"); context1.put("project", "Jakarta"); context1.put("duplicate", "I am in context1");
Cheetah takes a different approach. Rather than require you to manually populate the 'namespace' like Velocity, Cheetah will accept any existing Python object or dictionary AS the 'namespace'. Furthermore, Cheetah allows you to specify a list namespaces that will be searched in sequence to find a varname-to-value mapping. This searchList can be extended at run-time.
If you add a `foo' object to the searchList and the `foo' has an attribute
called 'bar', you can simply type $bar
in the template. If the
second item in the searchList is dictionary 'foofoo' containing
{'spam':1234, 'parrot':666}
, Cheetah will first look in the `foo'
object for a `spam' attribute. Not finding it, Cheetah will then go to
`foofoo' (the second element in the searchList) and look among its
dictionary keys for `spam'. Finding it, Cheetah will select
foofoo['spam']
as $spam
's value.