Example #1
0
 BootWeb.addTemplateDir(templatesDir, function(err, exist) {
   templatesDir = path.join(__dirname, "../lib/templates");
   BootWeb.addTemplateDir(templatesDir, function(err, exist) {
     // add condition for initializing
     if (BootWeb.templatesDirs.length > 0) {
       logger.info("Initializing swig engine");
       app.engine('.html', require('consolidate').swig);
       app.set('view engine', 'html');
       swig.init({
         root: BootWeb.templatesDirs,
         autoescape: false,
         allowErrors: true // allows errors to be thrown and caught by express
       });
       app.set('views', BootWeb.templatesDirs[0]);
       app.set('view options', {
         layout: false
       });
       BootWeb.swig = swig;
     }
     else {
       logger.error("Swig template engine not initialized");
       BootWeb.swig = null;
       throw new Error("Cannot initialize swig");
     }
     logger.info("swig initialization done");
     cb(null);
   });
 });