Comments in Jade/pug


Question

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?

1
75
1/9/2017 8:15:31 PM

Accepted Answer

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.

162
4/27/2017 2:51:55 AM

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

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon