init
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
const path = require('path');
|
||||
const hbs = require(path.resolve('node_modules', 'hbs'));
|
||||
|
||||
const registerPartialsWithExtensions = require('./utils/registerPartialsWithExtensions');
|
||||
|
||||
function toJSON (obj) {
|
||||
if (typeof obj === 'object') {
|
||||
return JSON.stringify(obj)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
module.exports.applyHbs = (app) => {
|
||||
const templates = path.resolve(__dirname, 'templates')
|
||||
registerPartialsWithExtensions(hbs, templates)
|
||||
hbs.registerHelper('toJSON', toJSON)
|
||||
app.engine('hbs', hbs.__express)
|
||||
app.set('views', templates)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,600,700,900&subset=cyrillic,cyrillic-ext"
|
||||
rel="stylesheet" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>{{ pageTitle }}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script src="{{resourceUrl}}/inno-bootstrap/{{versionBootstrap}}/dist/index.js"></script>
|
||||
<script>
|
||||
bootstrap({
|
||||
apps: {{{ toJSON apps }}},
|
||||
navigations: {{{ toJSON navigations }}},
|
||||
config: {{{ toJSON config }}}
|
||||
})
|
||||
</script>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,15 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const glob = require(path.resolve('node_modules', 'glob'));
|
||||
|
||||
module.exports = (hbs, rootDir) => {
|
||||
glob
|
||||
.sync(`${rootDir}/**/*`, {
|
||||
nodir: true
|
||||
})
|
||||
.forEach((m) => {
|
||||
const partialName = path.relative(rootDir, m).split(path.sep).join('/')
|
||||
hbs.registerPartial(partialName, fs.readFileSync(m, 'utf8'))
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user