title: pass a variable to ejs
body: <p>I'm trying to do what should be the simplest process of passing a variable to an ejs template to display in the browser.</p>
  
  <p>I read a file that contains only one string and assign the output to a variable.  This works fine and i can view the contents with console.log.  However, i can't figure out how to code the app.get and res.render part to send that variable to ejs (index.ejs).</p>
  
  <pre><code>var fs = require('fs');
  
  // Read the contents of the file into memory.
  fs.readFile('testfile.txt', function (err, log) {
  
  // If an error occurred, throwing it will
    // display the exception and end our app.
    if (err) throw err;
  
  // log is a Buffer, convert to string.
    var text = log.toString();
          console.log('The content of the log is' + text);
  });
  
  // index page
  app.get('/', function(req, res) {
      res.render('index', { var:  text }
      });
  
  app.listen(8080);
  console.log('8080 port');
  </code></pre>
  
  <p>Thanks.</p>