EJS with optional chaining
Hello, I would like to know if it would be possible to use EJS with the optional chaining option (described here). I'm currently using Babelify (Browserify transform for Babel) and it's possible to use the option by using an NPM.
So basically instead of writing this kind of code inside an EJS file:
<input type="text" value="<%= locals.cosmo ? locals.cosmo.names.en : '' %>" required />
We could write it this way:
<input type="text" value="<%= locals.cosmo?.names.en %>" required />
Thank you!
EJS doesn't support babel currently.
That's quite an issue.
It's not a feature that people are clamoring for, but I'd be happy to take a look at a PR that implements it.
Beside the fact it could be cool and very useful to support such functionalities, JavaScript is evolving, so EJS should do because it's based on.
My example with optional chaining is only one of them and users from today don't write JavaScript the same way they did years ago. So, if you could enhance the JS support it would be awesome!
+1 for optional chaining
+1 for optional chaining, could be useful in input validation with express-validator. (<%= errors?.username?.msg %>)
Edit: Update your node.js version to latest
+1 for optional chaining operator.
:+1:
Since Node v14.0.0, optional chaining is natively supported.