UNPKG

958 BJavaScriptView Raw
1export default class HTMLTool {
2
3 constructor() {
4 this.title = ''
5 this.metas = []
6 }
7
8 setTitle(title) {
9 this.title = title
10 }
11
12 getTitle() {
13 return this.title
14 }
15
16 addMeta(meta) {
17 this.metas.push(meta)
18 }
19
20 getMetaHtml() {
21 return this.metas.map((meta) => {
22 let str = '<meta'
23 for (var key in meta) {
24 str += ` ${key}="${meta[key]}"`
25 }
26 str += '>'
27 return str
28 }).join('')
29 }
30
31 getReduxScript(store) {
32 return `window.__REDUX_STATE__ = ${JSON.stringify(store.getState())};`
33 }
34
35 // convertToFullHtml(template = DEFAULT_TEMPLATE, inject = {}) {
36 // let html = template
37 // for (let key in inject) {
38 // html = html.replace(`<script>//inject_${key}</script>`, inject[key])
39 // }
40 // return html
41 // }
42}