From 6b39f4848198b4c56aef90022ab78b883e05fabe Mon Sep 17 00:00:00 2001 From: s2 Date: Thu, 5 Sep 2019 10:06:25 +0200 Subject: [PATCH] Show compiled templates in debugger This commit adds a sourceURL directive to the generated template function. This makes generated template code visible in the debugger. See https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Debug_eval_sources --- lib/ejs.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ejs.js b/lib/ejs.js index c65354c8..f67e5db7 100755 --- a/lib/ejs.js +++ b/lib/ejs.js @@ -610,6 +610,10 @@ Template.prototype = { if (opts.debug) { console.log(src); } + if (opts.compileDebug && opts.filename) { + src = src + '\n' + + '//# sourceURL=' + opts.filename + '\n'; + } try { if (opts.async) {