13.7 PSP-style tags

<%= ...%> and <% ...%> allow an escape to Python syntax inside the template. You do not need it to use Cheetah effectively, and we're hard pressed to think of a case to recommend it. Nevertheless, it's there in case you encounter a situation you can't express adequately in Cheetah syntax. For instance, to set a local variable to an elaborate initializer.

<%= ...%> encloses a Python expression whose result will be printed in the output.

<% ...%> encloses a Python statement or expression (or set of statements or expressions) that will be included as-is into the generated method. The statements themselves won't produce any output, but you can use the local function write(EXPRESSION) to produce your own output. (Actually, it's a method of a file-like object, but it looks like a local function.) This syntax also may be used to set a local variable with a complicated initializer.

To access Cheetah services, you must use Python code like you would in an inherited Python class. For instance, use self.getVar() to look up something in the searchList.

Warning: No error checking is done! If you write:

<% break %>      ## Wrong!
you'll get a SyntaxError when you fill the template, but that's what you deserve.

Note that these are PSP-style tags, not PSP tags. A Cheetah template is not a PSP document, and you can't use PSP commands in it.