5.1 Language Constructs - Summary

  1. Comments and documentation strings
    1. ## single line
    2. #* multi line *#

  2. Generation, caching and filtering of output
    1. plain text
    2. look up a value: $placeholder
    3. evaluate an expression: #echo ...
    4. same but discard the output: #silent ...
    5. one-line if: #if EXPR then EXPR else EXPR
    6. gobble the EOL: #slurp
    7. parsed file includes: #include ...
    8. raw file includes: #include raw ...
    9. verbatim output of Cheetah code: #raw ...#end raw
    10. cached placeholders: $*var, $*<interval>*var
    11. cached regions: #cache ...#end cache
    12. set the output filter: #filter ...
    13. control output indentation: #indent ...(not implemented yet)

  3. Importing Python modules and objects: #import ..., #from ...

  4. Inheritance
    1. set the base class to inherit from: #extends
    2. set the name of the main method to implement: #implements ...

  5. Compile-time declaration
    1. define class attributes: #attr ...
    2. define class methods: #def ...#end def
    3. #block ...#end block provides a simplified interface to #def ...#end def

  6. Run-time assignment
    1. local vars: #set ...
    2. global vars: #set global ...
    3. deleting local vars: #del ...

  7. Flow control
    1. #if ...#else ...#else if (aka #elif) ...#end if
    2. #unless ...#end unless
    3. #for ...#end for
    4. #repeat ...#end repeat
    5. #while ...#end while
    6. #break
    7. #continue
    8. #pass
    9. #stop

  8. error/exception handling
    1. #assert
    2. #raise
    3. #try ...#except ...#else ... #end try
    4. #try ...#finally ...#end try
    5. #errorCatcher ...set a handler for exceptions raised by $placeholder calls.

  9. Instructions to the parser/compiler
    1. #breakpoint
    2. #compiler-settings ...#end compiler-settings

  10. Escape to pure Python code
    1. evalute expression and print the output: <%= ... %>
    2. execute code and discard output: <% ...%>

  11. Fine control over Cheetah-generated Python modules
    1. set the source code encoding of compiled template modules: #encoding
    2. set the sh-bang line of compiled template modules: #shBang

The use of all these constructs will be covered in the next several chapters.