模板/蓝色文件夹中有test123.html
# blueprint 1
from flask import Blueprint
from echo.__init__ import echo_template
blue = Blueprint('blue', __name__)
@page.route('/test123')
def test():
return echo_template('test123', blue.name)
# blueprint 2 (for template helper)
from flask import render_template, Blueprint
echo = Blueprint('echo', __name__)
def echo_template(template_name, blue_name, **context):
file_name = blue_name + '/' + template_name + '.html'
return render_template(file_name, **context)
我可以这样打电话:
echo_template('name', 'blue_name', a="a")
但我想把它称为下面的
echo_template('name', a="a")
我需要一种方法从回显模糊中获取蓝图名称并自动添加到功能