@mkfe/js2html
v1.0.1
Published
通过js配置来生成Document字符串
Downloads
5
Readme
Useage
const getDocText = require('@mkfe/js2html');
const docText = getDocText({
title: 'bala',
meta: [
{
charset: 'utf-8'
},
{
name: 'viewport',
content: 'width=device-width, initial-scale=1'
}
],
link: {
'shortcut icon': '/static/favicon.ico',
'dns-prefetch': 'bala'
},
headScript: [
{
src: 'bala.js',
crossorigin: 'anonymous'
}
],
style: [
'static/a.css',
{
text: 'body {margin: 0;}'
}
],
bodyAttrs: {
class: 'body-development'
},
bodyHtml: ['<div id="app"></div>'],
script: [
'https://code.jquery.com/jquery-3.3.1.min.js',
{
src: 'bala.js',
crossorigin: 'anonymous'
},
{
text: 'console.log("monkeyfeiyu")'
}
]
});
console.log(docText);
Return
<!DOCTYPE html>
<html>
<head>
<title>bala</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="/static/favicon.ico" />
<link rel="dns-prefetch" href="bala" />
<link rel="stylesheet" href="static/a.css" />
<style>
body {
margin: 0;
}
</style>
<script src="bala.js" crossorigin="anonymous"></script>
</head>
<body class="body-development">
<div id="app"></div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="bala.js" crossorigin="anonymous"></script>
<script>
console.log('monkeyfeiyu');
</script>
</body>
</html>
Config
// documentConfig
{
title: 'bala',
meta: [
{
charset: 'utf-8'
},
{
name: 'viewport',
content: 'width=device-width, initial-scale=1'
}
],
link: {
'shortcut icon': '/static/favicon.ico',
'dns-prefetch': 'bala'
},
headScript: [
{
src: 'bala.js',
crossorigin: 'anonymous'
}
],
style: [
'static/a.css',
{
text: 'body {margin: 0;}'
}
],
bodyAttrs: {
class: 'body-development'
},
bodyHtml: [
'<div id="app"></div>'
],
script: [
'https://code.jquery.com/jquery-3.3.1.min.js',
{
src: 'bala.js',
crossorigin: 'anonymous'
},
{
text: 'console.log("123")'
}
]
}
mark
- npm publish --registry https://registry.npmjs.org