Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

renameAttr

M. Mikkel Rummelhoff edited this page Aug 18, 2016 · 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.