I'm using the module ejs for validating ejs template and variables that come from the admin dashboard:
try {
resolve(ejs.render(template, variables))
} catch (error) {
reject(error)
}
And if there are some issues with this template, it throws an error, and I can send it to the client.
Also, I have a mustache template to validate. I'm using the same approach:
try {
resolve(mustache.render(template, variables))
} catch (error) {
reject(error)
}
But mustache doesn't throw an error at all, and if there is no variable, it just replaces it with an empty string.
How can I solve this issue? Need to validate templates properly.
I have found a solution in this fork of the library. Thanks to Scott it works like should.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With