insert2

1.0.1 • Public • Published

insert2 NPM version NPM downloads Build Status

Insert string into HTML.

Install

$ npm install --save insert2

Usage

import insert from 'insert2'
 
const html = `
<html>
  <head>
    <title>hi</title>
  </head>
  <body>
  </body>
</html> 
`
 
insert(html, {
  string: '<link rel="stylesheet" href="style.css" />',
  el: 'head'
})
 
// returned
<html>
  <head>
    <title>hi</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
  </body>
</html> 

API

insert2(html, options)

html

Type: string
Default: ''

The original HTML string.

options

string

Type: String
Default: ''

The string to be inserted into HTML.

el

Type: String
Default: body

HTML tag name, the place to insert into.

type

Type: String
Default: append

append or prepend.

insertMulti(html, options: Array<object>)

Like insert2() but uses a list of options to do multiple insertions.

import {insertMulti} from 'insert2'

License

MIT © EGOIST

Readme

Keywords

Package Sidebar

Install

npm i insert2

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • kchan