I have been incorporating the ejs template into my express application. Following the guidance on the official page of the template (https://www.npmjs.com/package/ejs), I am utilizing an if conditional to display a variable only if it has been defined. Here is an example:
<% if (msg) { %>
<h2><%=msg %></h2>
<% } else { %>
<h2>There are no messages</h2>
<% } %>
The issue I am facing is that each time I implement this, the server returns a 500 error. How can I troubleshoot and resolve this problem?