【问题标题】:Static attributes in CheetahCheetah 中的静态属性
【发布时间】:2017-12-05 17:23:57
【问题描述】:

我正在使用 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()

可以这样做吗?

谢谢

【问题讨论】:

  • 抱歉回复晚了,我在医院。

标签: python python-3.x cheetah


【解决方案1】:

您正在寻找#attr

例子:

#attr className = "CustomClassName"

【讨论】:

    猜你喜欢
    • 2018-04-18
    • 1970-01-01
    • 2014-12-21
    • 2014-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-11
    相关资源
    最近更新 更多