title: include external html file and pass in variables
body: <p>I  <a href="https://stackoverflow.com/questions/4720343/loading-basic-html-in-nodejs">saw this post</a> on how to include an external html file and it works well.<br />
  <strong>Q:</strong> Is it possible to pass in variables from node into the html file?<br />
  node:</p>
  
  <pre><code>var http = require('http'), fs = require('fs');
  
  var mytitle = 'Bold Title';//&lt;&lt; pass this into the html markup
  
  fs.readFile('./markup.html', function (err, html) {
      if (err) {
              throw err; 
      } 
      exports.serve = function(req, res) {
          res.writeHead(200, {'Content-Type': 'text/html'})
          res.write(html);  
          res.end(); 
      };      
  
  });
  </code></pre>
  
  <p>html:</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html lang="en-US"&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
      &lt;p&gt; [mytitle] &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><br />
  <strong>The reason:</strong> the html markup will be quite large and if i pass the entire dom as a variable it gets messy and difficult to read.<br />
  Is there a better way to do this?</p>
  
  <pre><code>function page(req, res, pre, cb) {
  
      var mytitle = 'Bold Title';
  
      var content = '&lt;html&gt;\
      &lt;head&gt;&lt;/head&gt;\
      &lt;body&gt;\
      &lt;p&gt;'+mytitle+'&lt;/p&gt;\
      &lt;/body&gt;\
      &lt;/html&gt;';
  
      res.writeHead(200, {'Content-Type': 'text/html'})
      res.end(content);
      cb();
  }
  </code></pre>