title: What is the proper way to check for existence of variable in an EJS template (using ExpressJS)?
body: <p>On the EJS github page, there is one and only one simple example: 
  <a href="https://github.com/visionmedia/ejs">https://github.com/visionmedia/ejs</a></p>
  
  <p>Example</p>
  
  <pre><code>&lt;% if (user) { %&gt;
      &lt;h2&gt;&lt;%= user.name %&gt;&lt;/h2&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>This seems to be checking for the existence of a variable named user, and if it exists, do some stuff.  Duh, right?</p>
  
  <p>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?  </p>
  
  <pre><code>ReferenceError: user is not defined
      at IncomingMessage.anonymous (eval at &lt;anonymous&gt; (/usr/local/lib/node/.npm/ejs/0.3.1/package/lib/ejs.js:140:12))
      at IncomingMessage.&lt;anonymous&gt; (/usr/local/lib/node/.npm/ejs/0.3.1/package/lib/ejs.js:142:15)
      at Object.render (/usr/local/lib/node/.npm/ejs/0.3.1/package/lib/ejs.js:177:13)
      at ServerResponse.render (/usr/local/lib/node/.npm/express/1.0.7/package/lib/express/view.js:334:22)
      at Object.&lt;anonymous&gt; (/Users/me/Dropbox/Projects/myproject/server.js:188:9)
      at param (/usr/local/lib/node/.npm/connect/0.5.10/package/lib/connect/middleware/router.js:146:21)
      at pass (/usr/local/lib/node/.npm/connect/0.5.10/package/lib/connect/middleware/router.js:162:10)
      at /usr/local/lib/node/.npm/connect/0.5.10/package/lib/connect/middleware/router.js:152:27
      at Object.restrict (/Users/me/Dropbox/Projects/myproject/server.js:94:5)
      at param (/usr/local/lib/node/.npm/connect/0.5.10/package/lib/connect/middleware/router.js:146:21)
  </code></pre>
  
  <p>I understand that I could make this error go away by simply adding a "user" local variable in my server code, but the whole point here is that I want to check for the existence of such variables at runtime using your every day if/else nullcheck type pattern.  An exception for a variable that doesn't exist seems ridiculous to me.</p>