title: Reading Environment Variables from Node Views
body: <p>I'm starting to use NodeJs. I'm currently using Express to render a view, and I want to setup some conditionals. </p>
  
  <p>My development environment uses NodeMon and Reload to automatically refresh the browser each time I make modifications to the source code. I've setup my dependencies as follows: </p>
  
  <pre><code>{
    "scripts": {
      "start": "nodemon app.js"
    },
    "dependencies": {
      "express": "3.4.8",
      "ejs-locals": "1.0.2",
      "ejs": "*"
    },
    "devDependencies": {
      "nodemon": "1.0.14",
      "grunt": "*",
      "grunt-contrib-less": "~0.9.0",
      "grunt-contrib-cssmin": "~0.7.0",
      "reload": "~0.1.0"
    }
  }
  </code></pre>
  
  <p>This ensures that my production environment doesn't load up anything that's not really necessary for the app to run. </p>
  
  <p>Reload uses a javascript file located in <code>/reload/reload.js</code> in order to refresh the browser. This file is added on my main layout.ejs file so it runs on all views. </p>
  
  <p>I'm trying to do something like this so that it doesn't get rendered on the production server:</p>
  
  <pre><code>&lt;%if (process.env.NODE_ENV === 'development') { %&gt;
          &lt;script src="/reload/reload.js"&gt;&lt;/script&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <ul>
  <li>This doesn't work, <strong>what is the correct way to check for the current environment from the view?</strong> </li>
  <li>Is it OK to do so? does this violate some pattern? </li>
  <li>Should I just pass the current environment setting to the views directly from the controller?</li>
  </ul>