0.0.4 • Published 10 months ago

@jtorm/insert-method v0.0.4

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
10 months ago

jTorm Insert Method

Insert HTML in the Document Object Model (DOM) tree with help of the insertAdjacentHTML method. The following method aliases are available as well to set in the context methods: jTormAppendMethod = append/beforeend jTormPrependMethod = prepend/afterbegin jTormBeforeMethod = before/beforebegin jTormAfterMethod = after/afterend jTormReplaceMethod = replace/innerHTML

Install

npm install @jtorm/insert-method

Config

OptionRequiredTypeDescription
mtruestringMethod: a=append/beforeend, p=prepend/afterbegin, b=before/beforebegin, af=after/afterend, r=replace/innerHTML
hfalsehtmlHTML
dfalsedataWhen there are child items, alternative data to process can be set here
pfalsedataPrefix for 'h'
sfalsedataSuffix for 'h'
cidfalsedataCache id
csfalsedataCache scope

Example

body->insert {
    m: 'a';
    h: '<div><b>append me</b></div>';
    div {
        ->prepend {
            h: '<header><h3>Header</h3></header>';
        }

        ->append {
            h: '<footer>footer</footer>';
        }
    }
}
// Result: <div><header><h3>Header</h3></header><b>append me</b><footer>footer</footer></div>
body->insert {
m: 'a';
h: '<div><b>append me</b></div>';

    div {
        ->replace {
            s: 'h3';
            h: '<header><h3>Header</h3></header>';
        }
    }
}
// Result: <h3>Header</h3>
0.0.4

10 months ago

0.0.3

2 years ago

0.0.2

2 years ago