I'm trying to add some EJS to a yaml file. I want to use a default value if a variable is not provided to EJS but can't figure out how. Here are two attempts, both of which fail with the following error message:
postgres_credentials_secret_name is not defined
at eval (eval at compile (/Users/paymahn/code/goldsky/strick/infra/node_modules/ejs/lib/ejs.js:662:12), <anonymous>:107:17)
at anonymous (/Users/paymahn/code/goldsky/strick/infra/node_modules/ejs/lib/ejs.js:692:17)
at Object.exports.render (/Users/paymahn/code/goldsky/strick/infra/node_modules/ejs/lib/ejs.js:423:37)
at Immediate.run (/Users/paymahn/code/goldsky/strick/infra/node_modules/ejs/bin/cli.js:201:20)
at processImmediate (node:internal/timers:466:21) {
path: ''
}
attempt 1:
<% if(postgres_credentials_secret_name) { %>
name: <%- postgres_credentials_secret_name %>
<% } else { %>
name: graph-node-postgres-credentials
<% } %>
attempt 2:
name: <%- postgres_credentials_secret_name || 'graph-node-postgres-credentials' %>
How can I get EJS to not complain if a variable is not provided since I'm providing a default value in templating logic itself.