jinja2.contextfunction¶
-
jinja2.
contextfunction
(f)[source]¶ This decorator can be used to mark a function or method context callable. A context callable is passed the active
Context
as first argument when called from the template. This is useful if a function wants to get access to the context or functions provided on the context object. For example a function that returns a sorted list of template variables the current template exports could look like this:@contextfunction def get_exported_names(context): return sorted(context.exported_vars)