Skip to content

RenameAttr

M. Mikkel Rummelhoff edited this page Mar 5, 2018 · 1 revision

renameAttr lets you rename existing attributes for matching selectors, retaining the attribute values.

Usage/examples

Rename the src attribute to data-src for all <img> tags

{{ entry.body|retconRenameAttr('img', {src: 'data-src'}) }}

Rename the srcset and sizes attributes for all <img> tags

{{ entry.body|retconRenameAttr('img', {srcset: 'data-srcset', sizes: 'data-sizes'}) }}

Parameters

@selectors Mixed
String value or Array of string values
Examples: "p" ".foo" "#bar" "div.baz"

@attributes Array
Associative Array of existing attribute names and desired attribute names.