![]() |
Express is a small framework that sits on top of Node.js web server functionality to simplify its APIs and add helpful new features. It makes it easier to organize your application’s functionality with middleware and routing; it adds helpful utilities to Node.js’s HTTP objects; it facilitates the rendering of dynamic HTTP objects. In this article, we are going to learn how to use the pug engine in Express.js. Let us first start by creating a node.js project named pug. For that let’s create the folder named pug and run the command npm init in it. ![]()
Now that we have set up our project, let’s now install the necessary packages. First, we install Express.js, to install we will run the command: npm install express --save ![]()
Next, we will install pug. Run the following command to install: npm install pug --save ![]()
Now to set pug as the view engine, run the command: express --pug or express --view=pug ![]()
Now run the project by using the command: npm start Example: You can edit the content of the file index.pug to change the content of the screen. HTML
Output: ![]()
Now you are ready to start using the pug template engine in express in your projects. |
Reffered: https://www.geeksforgeeks.org
Express.js |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |