Q:

Changing jinja_env from a blueprint

I am trying to register a new jinja global on my blueprint using the Blueprint object. However, it appears that Blueprint objects do not have jinja_env attributes; how can I register a new jinja global attributes?
Here's the __init__.py of the blueprint, this does not work:
from flask import Blueprint, current_app

uploader = Blueprint('uploader', __name__, template_folder='templates')

from . import views
from . import models

current_app.jinja_env.globals['form_token'] = views.generate_form_token

Nor does this:
uploader.jinja_env.globals['form_token'] = views.generate_form_token

A:

Use the Blueprint.app_template_global decorator to register a global function to the jinja env.
uploader.app_template_global(views.generate_form_token)

Or in views.py:
@uploader.app_template_global
def generate_form_token():
    pass

