I am trying to add a function to the jinja environment from blue print (the function that I will use in the template).
Main.py
app = Flask(__name__) app.register_blueprint(heysyni)
MyBluePrint.py
heysyni = Blueprint('heysyni', __name__) @heysyni.route('/heysyni'): return render_template('heysyni.html',heysini=res_heysini)
Now in MyBluePrint.py , I would like to add something like:
def role_function(): return 'admin' app.jinja_env.globals.update(role_function=role_function)
Then I can use this function in my template. I canβt understand how I can access the application since
app = current_app._get_current_object()
return error
working outside of request context
How can I implement such a template?
gpasse
source share