Skip to content

Commit

Permalink
Added try catch in mustache render block
Browse files Browse the repository at this point in the history
  • Loading branch information
bautisflow committed Apr 12, 2024
1 parent 7413d29 commit f150e8d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,17 @@ class Utils {
} else if ( template !== null && typeof template !== 'undefined' ) {
let data = {};
// Render value of an object
for (const [key, subtemplate] of Object.entries(template)) {
if ( Utils.isTemplated(JSON.stringify(subtemplate)) )
data[key] = Utils.mustacheRender(subtemplate, views);
else data[key] = subtemplate;
try {
for (const [key, subtemplate] of Object.entries(template)) {
if ( Utils.isTemplated(JSON.stringify(subtemplate)) )
data[key] = Utils.mustacheRender(subtemplate, views);
else data[key] = subtemplate;
}
} catch (e) {
console.debug("Error rendering template: ", e);
console.debug("typeof template is: ", typeof template);
console.debug("template is: ", template);
return data;
}
return data;
} else {
Expand Down

0 comments on commit f150e8d

Please sign in to comment.