The |inserer_attribut{attribute, value} filter (since SPIP 1.8.2) is used to modify or add an HTML attribute to an HTML tag generated by the tag to which it is applied. [1]

For example:
[(#LOGO_DOCUMENT||inserer_attribut{alt, #TITRE|attribut_html})] modifies the "alt" attribute of the "img" HTML tag that is generated by the #LOGO_DOCUMENT tag by assigning it the document’s title as the value.

Il est aussi possible de vider un attribut en lui passant une valeur vide : [(#DESCRIPTIF|inserer_attribut{class, ''})]


[1The filter applies only to the first occurrence of the "attrubte" found; if there are no such occurrences found, then it is applied to the first "tag" that is found.
So [(#TEXTE|inserer_attribut{class, perso})] will modify the first "class" attribute that it finds in #TEXTE and only that one or alternatively, if there is no "class" attribute within #TEXTE at all, it will create a class="perso" for the first HTML tag that does exist within #TEXTE (by default on the opening <p>).

Author Mark Published : Updated : 26/10/12

Translations : català, English, Español, français, Nederlands