2023-03-05 14:56:16 +01:00
|
|
|
const express = require('express');
|
|
|
|
const router = new express.Router();
|
|
|
|
const Helpers = require('../helpers');
|
|
|
|
|
2023-03-05 15:26:56 +01:00
|
|
|
module.exports = (req, res, next) => {
|
2023-03-05 14:56:16 +01:00
|
|
|
if (res.template) return next();
|
2023-03-05 15:26:56 +01:00
|
|
|
|
|
|
|
|
2023-03-05 14:56:16 +01:00
|
|
|
res.template = async (file, data) => {
|
2023-03-09 14:26:00 +01:00
|
|
|
|
|
|
|
let t_data = {};
|
|
|
|
if (data) t_data = {...data};
|
|
|
|
|
2023-03-05 14:56:16 +01:00
|
|
|
res.send(await Helpers.ViewLoader.load(file, {
|
2023-03-09 14:26:00 +01:00
|
|
|
...t_data,
|
2023-03-05 14:56:16 +01:00
|
|
|
current_route: req.originalUrl,
|
|
|
|
req,
|
|
|
|
res,
|
|
|
|
require
|
|
|
|
}))
|
|
|
|
}
|
2023-03-05 15:26:56 +01:00
|
|
|
|
|
|
|
return next();
|
|
|
|
}
|