html-insert
v1.0.1
Published
页头页体插入css js 元数据
Downloads
2
Readme
html-insert
在html页面中注入代码
Install
$ npm install --save html-insert
Usage
var htmlXXXInject = require('html-insert');
htmlXXXInject.assetsInject('<html><head><title>inject</title></head><body>some text...</body></html>', {
assets: [
{
type: 'css',
url: 'http://foo.com/bar.css',
inject: 'head'
},
{
type: 'js',
url: 'http://foo.com/bar.js',
inject: 'body'
}
]
});
//=> '<html><head><title>inject</title><link rel="stylesheet" href="http://foo.com/bar.css" type="text/css" /></head><body>some text...<script type="text/javascript" src="http://foo.com/bar.js"></script></body></html>'
htmlXXXInject.headMetaDataInject('<html><head><title>inject</title></head><body>some text...</body></html>', '<meta charset="utf-8">');
//=> '<html><head><title>inject</title><meta charset="utf-8"></head><body>some text...</body></html>'
API
assetsInject(htmlContent, options)
注入静态资源引用
htmlContent
Type: string
options
Type: object
headMetaDataInject(htmlContent, metaData)
在head标签注入meta数据
htmlContent
Type: string
metaData
Type: string