UNPKG

koot

Version:

Koot.js - React isomorphic framework created by CMUX

44 lines (36 loc) 1.02 kB
export default class HTMLTool { constructor() { this.title = '' this.metas = [] } setTitle(title) { this.title = title } getTitle() { return this.title } addMeta(meta) { this.metas.push(meta) } getMetaHtml() { return this.metas.map((meta) => { let str = '<meta' for (var key in meta) { str += ` ${key}="${meta[key]}"` } // str += ` ${__KOOT_INJECT_ATTRIBUTE_NAME__}>` str += '>' return str }).join('') } getReduxScript(store) { return `window.__REDUX_STATE__ = ${JSON.stringify(store.getState())};` } // convertToFullHtml(template = DEFAULT_TEMPLATE, inject = {}) { // let html = template // for (let key in inject) { // html = html.replace(`<script>//inject_${key}</script>`, inject[key]) // } // return html // } }