raz
Version:
Razor like HTML template engine for NodeJS Express library based on ASP.NET MVC Razor syntax. Template your views by mixing HTML markup with JavaScript server-side code!
37 lines (32 loc) • 770 B
JavaScript
(function () {
module.exports = function (opts) {
opts = opts || {};
var exp = {};
if (opts.on) {
exp.debug = debug;
}
else {
exp.debug = noop;
}
return exp;
function debug(text) {
let funcName = callerName();
text = text || '';
console.debug(`[${funcName}]: ${text}`);
}
function noop() {}
};
// helpers:
function callerName() {
try {
throw new Error();
}
catch (e) {
try {
return e.stack.split('at ')[3].split(' ')[0];
} catch (e) {
return '';
}
}
}
})();