Cheetah's basic syntax was inspired by the Java-based template engines Velocity and WebMacro. It has two types of tags: $placeholders and #directives. Both types are case-sensitive.
Placeholder tags begin with a dollar sign (
$varName) and are similar to
data fields in a form letter or to the
%(key)s fields on the left side
% operator. When the template is filled, the placeholders
are replaced with the values they refer to.
Directive tags begin with a hash character (#) and are used for comments, loops, conditional blocks, includes, and all other advanced features. (Note: you can customize the start and end delimeters for placeholder and directive tags, but in this Guide we'll assume you're using the default.)
Placeholders and directives can be escaped by putting a backslash before them.
\#if will be output as literal text.
A placeholder or directive can span multiple physical lines, following the same
rules as Python source code: put a backslash (
\) at the end of all
lines except the last line. However, if there's an unclosed parenthesis,
bracket or brace pending, you don't need the backslash.
#if $this_is_a_very_long_line and $has_lots_of_conditions \ and $more_conditions: <H1>bla</H1> #end if #if $country in ('Argentina', 'Uruguay', 'Peru', 'Colombia', 'Costa Rica', 'Venezuela', 'Mexico') <H1>Hola, senorita!</H1> #else <H1>Hey, baby!</H1> #end if