title: Having a Node.JS Express template engine with multiple templates in one file
body: <p>I wrote a custom template engine to let me use my old templates in a rewrite of my current project. Everything is working except that Express.js always sends a </p>
  
  <pre><code>Error: Failed to lookup view (template name)
  </code></pre>
  
  <p>I have multiple templates in one file and I don't need one file for each template. But how can I tell that to Express?</p>
  
  <p>I can't get my head around this.
  Any help is appreciated</p>
  
  <p><strong>EDIT:</strong> Some Code:</p>
  
  <pre><code>My Express Setup: (app.js)
  
  var express = require('express');
  var app = express();
  var gclosure = require('./templateEngine');
  var fs = require('fs');
  
  /**
   * Setup Express
   */
  app.configure(function(){
  
      app.engine('test', gclosure.__express);
  
      app.set('views', __dirname + '/public/templates');
      app.set('view engine', 'test');
  
      app.use(express.favicon());
      app.use(express.bodyParser());
      app.use(express.cookieParser());
      app.use(express.methodOverride());
  
      app.use(require('less-middleware')({
          src: __dirname + '/public'
      }));
  
      app.use(express.static(__dirname + '/public'));
  });
  </code></pre>
  
  <p>My Custom Template Engine (templateEngine.js)</p>
  
  <pre><code>exports.renderFile =  function(path, options, fn){
  
    if ('function' == typeof options) {
      fn = options, options = {};
    }
  
    try {
  
      fm(null, "This is a test output");
  
    } catch (err) {
      fn(err);
    }
  };
  </code></pre>
  
  <p>My test route in express: </p>
  
  <pre><code>  app.get('/', function(req, res, next) {
  
      res.render('simple',{
                title: 'Sources',
                data: 'lala',
                options: 'miep'
            }); 
  
    });
  </code></pre>
  
  <p>The Clue is: When I create a file named <code>simple.test</code> in the template folder everything is working and I can see the test output string. When I change the name to something that doesn't exist the out put is </p>
  
  <pre><code>Error: Failed to lookup view (template name)
  </code></pre>