This repository has been archived by the owner on Oct 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Inject
M. Mikkel Rummelhoff edited this page Mar 3, 2015
·
4 revisions
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.
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 ) }}
@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