Installing the Swig template engine

The first step to do is to change the default express template engine to use Swig, a pretty simple template engine very flexible and stable, also offers us a syntax very similar to AngularJS which denotes expressions just by using double curly brackets {{ variableName }}.

Tip

More information about Swig can be found on the official website at: https://github.com/paularmstrong/swig.

  1. Open the package.json file and replace the jade line with the following:
          "swig": "^1.4.2",
    
  2. Open terminal/shell in project folder and type:
          npm install
    
  3. Before we proceed, let's make some adjustment to app.js, we need to add the Swig module. Open app.js and add the following code, right after the var bodyParser = require('body-parser'); ...

Get Node.js 6.x Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.