|
|
@ -1171,14 +1171,14 @@ class Flask(_PackageBoundObject): |
|
|
|
You can specify a name for the global function, otherwise the function |
|
|
|
You can specify a name for the global function, otherwise the function |
|
|
|
name will be used. Example:: |
|
|
|
name will be used. Example:: |
|
|
|
|
|
|
|
|
|
|
|
@app.template_global() |
|
|
|
@app.template_global() |
|
|
|
def double(n): |
|
|
|
def double(n): |
|
|
|
return 2 * n |
|
|
|
return 2 * n |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 0.10 |
|
|
|
.. versionadded:: 0.10 |
|
|
|
|
|
|
|
|
|
|
|
:param name: the optional name of the global function, otherwise the |
|
|
|
:param name: the optional name of the global function, otherwise the |
|
|
|
function name will be used. |
|
|
|
function name will be used. |
|
|
|
""" |
|
|
|
""" |
|
|
|
def decorator(f): |
|
|
|
def decorator(f): |
|
|
|
self.add_template_global(f, name=name) |
|
|
|
self.add_template_global(f, name=name) |
|
|
@ -1193,7 +1193,7 @@ class Flask(_PackageBoundObject): |
|
|
|
.. versionadded:: 0.10 |
|
|
|
.. versionadded:: 0.10 |
|
|
|
|
|
|
|
|
|
|
|
:param name: the optional name of the global function, otherwise the |
|
|
|
:param name: the optional name of the global function, otherwise the |
|
|
|
function name will be used. |
|
|
|
function name will be used. |
|
|
|
""" |
|
|
|
""" |
|
|
|
self.jinja_env.globals[name or f.__name__] = f |
|
|
|
self.jinja_env.globals[name or f.__name__] = f |
|
|
|
|
|
|
|
|
|
|
|