![]() |
VOOZH | about |
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.
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.
// Single line Comment.Multiline Syntax for multiline comment
//-
Multiline Comment
Multiline Comment
Step 1: Create a NodeJS Application using the following command:
npm init -yStep 2: Install required dependencies using the following command:
npm i pug expressStep 3: Create a views folder that contains the comment.pug file.
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.jsThe comment that takes only one line to describe any information is called as single line comment.
Example: Below is an example of Pug Single Line Comment.
Output:
The comments that takes only multiple lines to describe any information is called as single line comment.
Example: Below is an example of Pug Multiple Line Comment.
Output: