3
好吧,在python運行以下命令:爲什麼Mako不能找到包含它的模板?
from mako.lookup import TemplateLookup
from mako.template import Template
mylookup = TemplateLookup(directories=['/home/user/webapps/app/www/templates/'])
mytemplate = Template(filename='/home/user/webapps/app/www/templates/content.html.mako', lookup=mylookup)
print (mytemplate.render(title="Title", content={'hi'}))
當這是content.html.mako
## content.html.mako
<%inherit file="frame.html.mako"/>
的開頭給了我這樣的:
mako.exceptions.TemplateLookupException: Cant locate template for uri '/home/user/webapps/app/www/templates/frame.html.mako'
但frame.html.mako
是與content.html.mako
相同的目錄,這裏發生了什麼?
但是如果您的模板包含具有相對路徑的另一個模板,則mako仍然不起作用。 – 2017-09-21 11:00:18