The |inserer_attribut{attribute, value} filter is used to modify or add an html attribute in an html tag generated by the tag to which it is applied.

  • New in : SPIP 1.8.2

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.

modifies the "alt" attribute of the "img" html tag generated by the #LOGO_DOCUMENT tag, assigning the document title as the value.

More precisely...

The filter is only applied to the first occurrence of an "attribute"; if no such occurrence is found, then it is applied to the first "tag" encountered.


[(#TEXTE|inserer_attribut{class, perso})]

...will modify the first "class" attribute encountered in #TEXTE and only that or, if no "class" attribute is present in #TEXTE, will create a class="perso" in the first html tag present in #TEXTE (by default, in the opening <p>).

See also


Author Mark Published : Updated : 22/07/23

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