From 6ed2b48d36eeeb7f71e79e86eb9c02741d270fae Mon Sep 17 00:00:00 2001 From: s2 Date: Fri, 7 Feb 2020 20:50:01 +0100 Subject: [PATCH] log async ejs compile error to console --- ejs-render-remote.js | 14 +++++++++----- examples/templates/hello.ejs | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ejs-render-remote.js b/ejs-render-remote.js index 860ad5c..d5efdea 100644 --- a/ejs-render-remote.js +++ b/ejs-render-remote.js @@ -40,11 +40,15 @@ getTemplateFn.then(function(template) { var templateOptions = overwriteWithCacheOptions(options, templateUrl); - $('#' + r).replaceWith(ejs.render( - template, - data, - templateOptions - )); + try { + $('#' + r).replaceWith(ejs.render( + template, + data, + templateOptions + )); + } catch(ex) { + console.error(templateUrl, ex); + } //clean up the getFnFor if (ejs.cache.remove && ejs.cache.get('getFnFor' + templateUrl)) { diff --git a/examples/templates/hello.ejs b/examples/templates/hello.ejs index eb1fabd..81f8da5 100644 --- a/examples/templates/hello.ejs +++ b/examples/templates/hello.ejs @@ -1 +1 @@ -Hello <%= name%>! +Hello <%= name %>!