5.5 NameMapper Syntax

One of our core aims for Cheetah was to make it easy for non-programmers to use. Therefore, Cheetah uses a simplified syntax for mapping placeholders in Cheetah to values in Python. It's known as the NameMapper syntax and allows for non-programmers to use Cheetah without knowing (a) the difference between an instance and a dictionary, (b) what functions and methods are, and (c) what 'self' is. A side benefit is that you can change the underlying data structure (e.g., instance to dictionary or vice-versa) without having to modify the templates.

NameMapper syntax is used for all variables in Cheetah placeholders and directives. If desired, it can be turned off via the Template class' 'useNameMapper' compiler setting. But it's doubtful you'd ever want to turn it off.



Subsections