title: Server Side rendering in mongo with dust
body: <p>Is it possible to fetch data from MongoDB and render a html template on the server side itself for a node-js project? </p>
  
  <p>As of now in my serverside js file I've done the following.</p>
  
  <pre><code>//Failing array will be populated by a db.find later on.
  var failing = [
      { name: "Pop" }, 
      { name: "BOB" }
  ];
  
  /*Now i have to send a mail from the server for which I'm using nodemailer.
   Where do i store the template ?  This is what I've done in the same file */
  
  var template = "&lt;body&gt;{#failing} &lt;p&gt;{.name}&lt;/p&gt; {/failing}&lt;/body&gt;"
  
  // Add this as the body of the mail and send it.
  
  </code></pre>
  
  <p>I'm not sure how to render the data and how to get it displayed. I'm aware storing the template in the variable isn't right but I'm not sure what else to do.</p>