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.
Open the
package.json
file and replace thejade
line with the following:"swig": "^1.4.2",
Open terminal/shell in project folder and type:
npm install
Before we proceed, let's make some adjustment to
app.js
, we need to add theSwig
module. Openapp.js
and add the following code, right after thevar bodyParser = require('body-parser');
line:var swig = require('swig');
Replace the default
jade
template engine line for the following code:var swig = new swig.Swig(); app.engine('html', swig.renderFile); app.set('view engine', 'html');