UNPKG

zents

Version:

ZenTS is a Node.js & TypeScript MVC-Framework for building rich web applications, released as free and open-source software under the MIT License. It is designed for building web applications with modern tools and design patterns.

35 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Loader = void 0; const path_1 = require("path"); const config_1 = require("../config/config"); const FS_1 = require("../filesystem/FS"); const fs_1 = require("fs"); class Loader { constructor(templateFiles) { var _a; this.templates = new Map(); const files = templateFiles.map((filePath) => path_1.parse(filePath)); let basePath = FS_1.fs.resolveZenPath('view'); if (basePath.endsWith(path_1.sep)) { basePath = basePath.slice(0, -1); } for (const file of files) { const filePath = path_1.join(file.dir, file.base); let key = file.dir.replace(basePath, '').substr(1).replace(path_1.sep, '/'); key += key.length ? `/${file.name}` : file.name; this.templates.set(key, { path: filePath, src: fs_1.readFileSync(filePath, { encoding: config_1.config.template.encoding, }), noCache: (_a = config_1.config.template.noCache) !== null && _a !== void 0 ? _a : false, }); } } getSource(key) { return this.templates.get(key); } } exports.Loader = Loader; //# sourceMappingURL=Loader.js.map