|
|
@ -185,17 +185,30 @@ class Blueprint(_PackageBoundObject): |
|
|
|
return f |
|
|
|
return f |
|
|
|
return decorator |
|
|
|
return decorator |
|
|
|
|
|
|
|
|
|
|
|
def app_template_filter(self, name = None): |
|
|
|
def app_template_filter(self, name=None): |
|
|
|
"""Like :meth:`Flask.template_filter` but for a blueprint. The filter |
|
|
|
"""Register a custom template filter, available application wide. Like |
|
|
|
is available for the entire application. |
|
|
|
:meth:`Flask.template_filter` but for a blueprint. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:param name: the optional name of the filter, otherwise the |
|
|
|
|
|
|
|
function name will be used. |
|
|
|
""" |
|
|
|
""" |
|
|
|
def decorator(f): |
|
|
|
def decorator(f): |
|
|
|
def register_template(state): |
|
|
|
self.add_app_template_filter(f, name=name) |
|
|
|
state.app.jinja_env.filters[name or f.__name__] = f |
|
|
|
|
|
|
|
self.record_once(register_template) |
|
|
|
|
|
|
|
return f |
|
|
|
return f |
|
|
|
return decorator |
|
|
|
return decorator |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_app_template_filter(self, f, name=None): |
|
|
|
|
|
|
|
"""Register a custom template filter, available application wide. Like |
|
|
|
|
|
|
|
:meth:`Flask.add_template_filter` but for a blueprint. Works exactly |
|
|
|
|
|
|
|
like the :meth:`app_template_filter` decorator. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:param name: the optional name of the filter, otherwise the |
|
|
|
|
|
|
|
function name will be used. |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
def register_template(state): |
|
|
|
|
|
|
|
state.app.jinja_env.filters[name or f.__name__] = f |
|
|
|
|
|
|
|
self.record_once(register_template) |
|
|
|
|
|
|
|
|
|
|
|
def before_request(self, f): |
|
|
|
def before_request(self, f): |
|
|
|
"""Like :meth:`Flask.before_request` but for a blueprint. This function |
|
|
|
"""Like :meth:`Flask.before_request` but for a blueprint. This function |
|
|
|
is only executed before each request that is handled by a function of |
|
|
|
is only executed before each request that is handled by a function of |
|
|
|