- Node.js 6.x Blueprints
- Fernando Monteiro
- 144字
- 2021-07-14 10:35:04
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');
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');
推薦閱讀
- Java語言程序設計
- Learn Type:Driven Development
- Angular UI Development with PrimeNG
- 深度學習經典案例解析:基于MATLAB
- Dynamics 365 Application Development
- 實戰Java程序設計
- Learn Swift by Building Applications
- 零基礎學Java程序設計
- AppInventor實踐教程:Android智能應用開發前傳
- Java實戰(第2版)
- C#開發案例精粹
- 從零開始學Python網絡爬蟲
- Vue.js 3應用開發與核心源碼解析
- Three.js Essentials
- 虛擬現實:引領未來的人機交互革命