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:

Folder 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.

Similar Reads

Comments in Pug

Comments are used to explain the code , to set reminders, or instructions for developers who are collaborating on the same project. It can be used to prevent the execution of a section of code if necessary. Comments are not displayed on browsers while rendering the page making them useful to add additional information without affecting the appearance of the webpage. We can comment single line of code or the multiple line of the code....

Approach to add Comments in Pug View Engine

Setting Up ExpressJS: The code initializes an Express.js server.Setting View Engine: It sets Pug as the view engine for rendering templates.Routing: There’s a single route defined for the root URL (/). When a user accesses this URL, it renders the Pug template.Pug Template: The Pug template defines the structure and styling of the HTML page. Styling: The styling is done using CSS embedded within the Pug template (style.). It sets styles for the body, headings, and container....

Steps to Create a Pug List Application

Step 1: Create a NodeJS Application using the following command:...

Single Line Comment

The comment that takes only one line to describe any information is called as single line comment....

Multiple Line Comment

The comments that takes only multiple lines to describe any information is called as single line comment....