Comments in Jade/pug

node.jsPug

node.js Problem Overview


I tried making comments in Jade/pug, but the comments render as text in the HTML. This is my code:

doctype html

html(lang='en')
    body
        / This should be a comment

What am I doing something stupid?

node.js Solutions


Solution 1 - node.js

As written in the comment documentation, you can either use // which will translate to a HTML comment or //- which won't be visible in the outputted HTML code.

Solution 2 - node.js

In jade we use //- for comment. If you are trying to comment a block, make sure it should be indented properly like in below example-

doctype html

html(lang='en')
    body
        //- 
            This should be a comment
            Indent correctly for block content

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRandomblueView Question on Stackoverflow
Solution 1 - node.jsalessioalexView Answer on Stackoverflow
Solution 2 - node.jsIRSHADView Answer on Stackoverflow