5.3 Where can you use placeholders?

There are three places you can use placeholders: top-level position, expression position and LVALUE position. Each has slightly different syntax rules.

Top-level position means interspersed in text. This is the only place you can use the placeholder long form: ${var}.

Expression position means inside a Cheetah expression, which is the same as a Python expression. The placeholder names a searchList or other variable to be read. Expression position occurs inside () and $[]$ arguments within placeholder tags (i.e., a placeholder inside a placeholder), and in several directive tags.

LVALUE position means naming a variable that will be written to. LVALUE is a computer science term meaning ``the left side of an assignment statement''. The first argument of directives #set, #for, #def, #block and #attr is an LVALUE.

This stupid example shows the three positions. Top-level position is shown in courier, expression position is italic, and LVALUE position is bold.

#for $count in $range($ninetyNine, 0, -1)
#set $after = $count - 1
$count bottles of beer on the wall. $count bottles of beer!
    Take one down, pass it around. $after bottles of beer on the wall.
#end for
$hex($myVar, $default=None)

The output of course is:

99 bottles of beer on the wall.  99 bottles of beer!
    Take one down, pass it around.  98 bottles of beer on the wall.
98 bottles of beer on the wall.  98 bottles of beer!
    Take one down, pass it around.  97 bottles of beer on the wall.
...