Search code examples
node.jsexpressswig-template

Express generator with Swig


I'm trying to use Express generator to create the application skeleton, however it seems to work only with Jade and EJS.

I don't like the idea from Jade of not using tags, because the code becomes a complete mess. And I already started working with Swig, but there aren't any options for it on Express generator.

How can I create this common structure using Express and Swig faster?


Solution

  • Refer Swig with Express.js

    In that there is option to change the default engine from Jade to HTML

    var app = require('express')(),
      swig = require('swig'),
      people;
    
    // This is where all the magic happens!
    app.engine('html', swig.renderFile);
    
    app.set('view engine', 'html');