text: var express = require('express');
  var path = require('path');
  var favicon = require('static-favicon');
  var logger = require('morgan');
  var cookieParser = require('cookie-parser');
  var bodyParser = require('body-parser');
  var jspl = require('../../lib/jspl');
  
  var routes = require('./routes/index');
  
  var app = express();
  
  // view engine setup
  app.set('views', path.join(__dirname, 'views'));
  app.set('view cache', false);
  
  // Bind JSPL to express
  jspl.bind(app);
  
  app.use(favicon());
  app.use(logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded());
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  
  app.use('/', routes);
  
  /// catch 404 and forward to error handler
  app.use(function(req, res, next) 
  {
      var err = new Error('Not Found');
      err.status = 404;
      next(err);
  });
  
  /// error handlers
  app.use(function(err, req, res, next) 
  {
      console.error('Intercept an error: ' + err);
      console.error(err);
      res.json(500, err.message);
  });
  
  
  module.exports = app;
  