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.
- 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'); ...
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.