What is the proper way to check for existence of variable in an EJS template (using ExpressJS)?
On the EJS github page, there is one and only one simple example: https://github.com/visionmedia/ejs Example <% if (user) { %> <h2><%= user.name %></h2> <% } %> This seems to be checking for the existence of a variable named user, and if it exists, do some stuff. Duh, right? My question is, why in the world would Node throw a ReferenceError if the user variable doesn't exist? This renders the above example useless. What's the appropriate way to check for the existence of a variable? Am I expected to use a try/catch mechanism and grab that ReferenceError? ReferenceError: user is not defined at