Skip to content

Commit

Permalink
Don't use template literal
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Apr 20, 2022
1 parent faf8b84 commit 076dcb6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ Template.prototype = {
for (var i = 0; i < opts.destructuredLocals.length; i++) {
var name = opts.destructuredLocals[i];
if (!_JS_IDENTIFIER.test(name)) {
throw new Error(`destructuredLocals[${i}] is not a valid JS identifier.`);
throw new Error('destructuredLocals[' + i + '] is not a valid JS identifier.');

This comment has been minimized.

Copy link
@hsynlms

hsynlms Apr 21, 2022

May I ask why is that?

This comment has been minimized.

Copy link
@mde

mde Apr 21, 2022

Author Owner

Because EJS has to run in older runtimes. Template literals have been around for a while now, but there are still some older JS runtimes that don't support them. What we really should be doing is explicitly stating which older runtimes we support.

This comment has been minimized.

Copy link
@hsynlms

hsynlms Apr 22, 2022

I see. Thank you for the explanation. Another question popped into my mind, why does EJS have to run in older runtimes?

This comment has been minimized.

Copy link
@mde

mde Apr 23, 2022

Author Owner

EJS has been around (in various forms) for a very, very long time (since the early 2000s at least). This version on NPM is installed between 7 and 10 million times a week. A large number of those are build processes or applications that run in older versions of Node. The mantra of JavaScript and the TC39 has always been "don't break the Web," and I follow that for EJS as well.

}
if (i > 0) {
destructuring += ',\n ';
Expand Down

0 comments on commit 076dcb6

Please sign in to comment.