I have a simple if statement in EJS (inside a partial):
<% if (('$_ENV.NODE_ENV',locals)==='production') { %> URL goes here <% } %>
This expression never goes through. So I was debugging it and turns out, if I put this:
<%=_('$_ENV.NODE_ENV',locals)%>
It’ll return production
But when I remove the ‘whitespace slurping’ _
from the expression, it doesn’t evaluate it anymore:
<%-('$_ENV.NODE_ENV', locals)%>
Gives me the error Cannot convert object to primitive value
.
This is very odd to me as I don’t understand why it now suddenly became an object?
The only way I could get some info is by doing
<%-JSON.stringify(('$_ENV.NODE_ENV', locals))%>
But this just returns the entire $_ENV object…
What am I doing wrong here? How can I make a simple if condition?
Community Page
Last updated:
Last updated: