Steps to Create a Pug List Application
Step 1: Create a NodeJS Application using the following command:
npm init -y
Step 2: Install required dependencies using the following command:
npm i pug express
Step 3: Create a views folder that contains the comment.pug file.
Project Structure:
The updated dependencies in package.json file will look like:
"dependencies": {
"express": "^4.18.2",
"pug": "^3.0.2"
}
To Run the Project:
node app.js
Comments in Pug View Engine
Pug is a template engine for NodeJS and browsers to render dynamic reusable content. At compile time, the template engine compiles our Pug template code to HTML. Pug has many powerful features like conditions, loops, includes, etc. using which we can render HTML code based on user input or reference data. Pug also supports JavaScript natively, hence using JavaScript expressions, we can format HTML code.