Getting ready

In this recipe, you will build your own template engine. To develop and use your own template engine, you will first need to register it, then define the path where the views are located, and finally tell ExpressJS which template engine to use.

      app.engine('...', (path, options, callback) => { ... }); 
      app.set('views', './'); 
      app.set('view engine', '...'); 

Before you start, create a new package.json file with the following content:

      { 
          "dependencies": { 
              "express": "4.16.3" 
          } 
      } 

Then, install the dependencies by opening a terminal and running:

       npm install
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.217.131