1

我正在使用 Cheetah 进行一个项目。我想创建一个像下面这样的类:

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

然后我希望能够在我的一个模板中执行以下操作:

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

是否有可能做到这一点 ?

谢谢

4

1 回答 1

0

您正在寻找#attr

例子:

#attr className = "CustomClassName"
于 2017-12-08T15:16:25.420 回答