This commit is contained in:
2020-03-07 19:50:28 +03:00
commit feaa706ab9
6 changed files with 278 additions and 0 deletions
+19
View File
@@ -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)
}