feature(template) add: read all templates on start

This commit is contained in:
coderaiser 2017-09-27 13:05:37 +03:00
parent 29ac0677af
commit 671101d201
2 changed files with 32 additions and 50 deletions

28
server/template.js Normal file
View file

@ -0,0 +1,28 @@
'use strict';
const fs = require('fs');
const join = require('path').join;
const DIR = __dirname + '/../';
const DIR_TMPL = DIR + 'tmpl/';
const DIR_FS = DIR_TMPL + 'fs/';
const TMPL_PATH = [
'file',
'panel',
'path',
'pathLink',
'link',
];
module.exports = () => {
const templates = {};
TMPL_PATH.forEach((name) => {
const path = join(DIR_FS, `${name}.hbs`);
templates[name] = fs.readFileSync(path, 'utf8');
});
return templates;
};