如何使用web.py编写自定义渲染器

2024-09-30 18:22:43 发布

您现在位置:Python中文网/ 问答频道 /正文

作为python和web.py的新手,我不确定我想要的是否可能,但我正在尝试为我的模板分配唯一的渲染器,以便我的模板不能使用特定的文件结构

因此,我: 代码.py

Main = web.template.render('templates/', globals=common_globals)
Section1 = web.template.render('templates/Section1/', globals=common_globals)

后来在引用这些时

这项工作:

class index:
def GET(self):
    vPage = '0'
    vLevel = '0'
    vSection = '0'
    return Main.Layout(vPage, vLevel, vSection)

但这并不是:

class Section1:
def GET(self):
    vPage = '0'
    vLevel = '1'
    vSection = '1'
    return Section1.Layout(vPage, vLevel, vSection)

任何关于这是否可能或者它如何工作的建议都是很好的


Tags: py模板webmaindeftemplatecommonrender