对python和web.py不熟悉,我不确定我的想法是否可行,但我正在尝试为我的模板分配唯一的渲染器,以便我的模板无法使用特定的文件结构。
所以我有: code.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)
关于这是否可行或如何运作的任何建议都很可爱。
答案 0 :(得分:0)
我在问题中没有找到答案。
我认为问题出在Layout.html中,但所有零都无法正常工作,因为变量默认为零。
不确定这是什么时候的确切版本,但是Layout.html的有效版本正在使用类似的内容:
$def with (vPage, vLevel, vDivision)
$:getNavigationHeader()
Univeersal.py具有
def getNavigationHeader():
vResult = ''
vResult += '<h4>'
vResult += 'Navigation'
vResult += '</h4>'
return vResult
所有方法都有类似的模式。