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

Inject HTML or String value into matching selectors.

Injected content will be appended to the container – unless you pass true for the @overwrite argument, in which case all existing content in the container will be removed.

Usage/examples

Inject a string into all <p> tags

{{ entry.body | retconInject( 'p', 'Hello world!' ) }}

Inject a string into all <p> and <span> tags

{{ entry.body | retconInject( [ 'p', 'span' ], 'Hello world!' ) }}

Inject HTML into all elements with the classname ".foo"

{{ entry.body | retconInject( '.foo', '<div class="myInjectedContainer">Hello world!</div>' ) }}

Inject HTML into all elements with the classname ".foo", replacing existing content

{{ entry.body | retconInject( '.foo', '<div class="myInjectedContainer">Hello world!</div>', true ) }}

Parameters

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

@toInject String
The content you want to inject.

@overwrite Boolean
Optional, default false If true, removes any existing content in the container