Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les fondamentaux
Voir le programme détaillé
Module « flask »

Fonction get_template_attribute - module flask

Signature de la fonction get_template_attribute

def get_template_attribute(template_name: 'str', attribute: 'str') -> 't.Any' 

Description

help(flask.get_template_attribute)

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 :file:`_cider.html` with the following contents:

.. sourcecode:: html+jinja

   {% 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')

.. versionadded:: 0.2

:param template_name: the name of the template
:param attribute: the name of the variable of macro to access


Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les compléments
Voir le programme détaillé