![]() |
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 in PugComments 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. Syntax for single line comment// Single line Comment. Multiline Syntax for multiline comment //- Approach to add Comments in Pug View Engine
Steps to Create a Pug List ApplicationStep 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": { To Run the Project: node app.js Single Line CommentThe 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: Multiple Line CommentThe 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: |
Reffered: https://www.geeksforgeeks.org
Node.js |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 16 |