bottle.py 模板路径有什么问题?
What's wrong with bottle.py template paths?
我正在尝试将国际化添加到我的页面。比方说,路线是 /RU/index
@route('/<path>/<page:re:.*>')
def callback(path, page):
fullpath = ('/%s/%s.html' % (path, page))
print('fullpath %s' % fullpath)
return template(fullpath)
为什么它 return 模板来自 /views/RU/index.html?
只需将路径添加到 TEMPLATE_PATH
def bottle_monkeypatch():
"""
This adds /common folder to bottle template path, thus
makes templating cleaner and more manageable.
"""
from bottle import TEMPLATE_PATH
global TEMPLATE_PATH
TEMPLATE_PATH.insert(0, './views/common')
我正在尝试将国际化添加到我的页面。比方说,路线是 /RU/index
@route('/<path>/<page:re:.*>')
def callback(path, page):
fullpath = ('/%s/%s.html' % (path, page))
print('fullpath %s' % fullpath)
return template(fullpath)
为什么它 return 模板来自 /views/RU/index.html?
只需将路径添加到 TEMPLATE_PATH
def bottle_monkeypatch():
"""
This adds /common folder to bottle template path, thus
makes templating cleaner and more manageable.
"""
from bottle import TEMPLATE_PATH
global TEMPLATE_PATH
TEMPLATE_PATH.insert(0, './views/common')