alapa
Version:
A cutting-edge web development framework designed to revolutionize the way developers build modern web applications.
36 lines (35 loc) • 1.14 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NunJunksLoader = void 0;
const nunjucks_1 = require("nunjucks");
const path_1 = __importDefault(require("path"));
const main_1 = require("../component/main");
class NunJunksLoader extends nunjucks_1.Loader {
req;
res;
constructor() {
super();
}
async;
getSource(templatePath) {
if (!path_1.default.isAbsolute(templatePath)) {
templatePath = path_1.default.resolve("views", templatePath);
}
try {
const template = main_1.Component.compileFile(templatePath).toString();
return {
src: template,
path: templatePath,
noCache: true,
};
}
catch (e) {
console.error(`Error loading template: ${templatePath}`);
return { src: `${e}`, path: templatePath, noCache: true };
}
}
}
exports.NunJunksLoader = NunJunksLoader;
;