flask.get_template_attribute¶
-
flask.
get_template_attribute
(template_name, attribute)[source]¶ Loads a macro (or variable) a template exports. This can be used to invoke a macro from within Python code. If you for example have a template named
_cider.html
with the following contents:{% macro hello(name) %}Hello {{ name }}!{% endmacro %}
You can access this from Python code like this:
hello = get_template_attribute('_cider.html', 'hello') return hello('World')
New in version 0.2.
Parameters: - template_name – the name of the template
- attribute – the name of the variable of macro to access