title: Load templates from existing file
body: <p>I'm using <code>Handlebars</code>  in my NodeJS application as my templating engine.</p>
  
  <p>I've put all my templates in a <code>views</code>  folder like so : </p>
  
  <pre><code>-
    - /controllers
    - /views
      - index.html
    - server.js
  </code></pre>
  
  <p>Here's my code to render the template when the user access a given URL (using <code>express</code> for routing) :  </p>
  
  <pre><code>app.get("/", function(req, res){
  
      var template = handlebars.compile("views/index.html");
      var data = {"name": "Charles"};
      var result = template(data);
  
      res.send(result);
  });
  </code></pre>
  
  <p>I'm trying to render a template from a file, but it's not working. This is  what the browser outputs directly when I'm accessing the <code>/</code>  URL : </p>
  
  <pre><code>views/index.html
  </code></pre>
  
  <p>That makes sense, since it's interpreting the given param as a string directly and not as  a path to an external template. </p>
  
  <p>How can I load my template file (in this case the one in <code>views/index.html</code>  to a variable, so that I can then render the template?</p>
  
  <p>The only examples I found were storing all the templates in a file and loading them via AJAX, but all these examples were from "front-end" handlebars and not when using it with Node.</p>
  
  <p>Is it possible to achieve what I want? I looked at the documentation but it's hard to find good infos for handlebars with NodeJS.</p>