Static attributes in Cheetah

64 Views Asked by At

I'm working on a project using Cheetah. I'd like to create a class like the following one:

from Cheetah.Template import Template
class TemplateObject(Template):
    className = "Default ClassName"
    def header(self):
        return "My Class name is {}".format(type(self).className)

and then i'd like to be able in one of my template to do something like:

#extends TemplateObject
#staticarg className = "CustomClassName" ## Something to declare a static member ?
$self.header()

is it possible to do this ?

Thank you

1

There are 1 best solutions below

0
On

You're looking for #attr.

Example:

#attr className = "CustomClassName"