diff --git a/src/middleware/index.js b/src/middleware/index.js index b1e065b3fd..2f995f7b5d 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -211,7 +211,7 @@ middleware.templatesOnDemand = function (req, res, next) { if (!filePath.endsWith('.js')) { return next(); } - + var tplPath = filePath.replace(/\.js$/, '.tpl'); if (workingCache[filePath]) { workingCache[filePath].push(next); return; @@ -234,11 +234,11 @@ middleware.templatesOnDemand = function (req, res, next) { } workingCache[filePath] = [next]; - fs.readFile(filePath.replace(/\.js$/, '.tpl'), 'utf8', cb); + fs.readFile(tplPath, 'utf8', cb); }, function (source, cb) { if (!source) { - return cb(new Error('[[error:templatesOnDemand.source-template-empty]]')); + return cb(new Error('[[error:templatesOnDemand.source-template-empty, ' + tplPath + ']]')); } Benchpress.precompile({ source: source, @@ -247,7 +247,7 @@ middleware.templatesOnDemand = function (req, res, next) { }, function (compiled, cb) { if (!compiled) { - return cb(new Error('[[error:templatesOnDemand.compiled-template-empty]]')); + return cb(new Error('[[error:templatesOnDemand.compiled-template-empty, ' + tplPath + ']]')); } fs.writeFile(filePath, compiled, cb); },