Comments
Buffered comments look the same as single-line JavaScript comments. They act sort of like markup tags, producing HTML comments in the rendered page.
Like tags, buffered comments must appear on their own line.
// just some paragraphs p foo p bar
<!-- just some paragraphs--> <p>foo</p> <p>bar</p>
Pug also supports unbuffered comments. Simply add a hyphen (-
) to the start of the comment.
These are only for commenting on the Pug code itself, and do not appear in the rendered HTML.
//- will not output within markup p foo p bar
<p>foo</p> <p>bar</p>
Block Comments
Block comments work, too:
body //- Comments for your template writers. Use as much text as you want. // Comments for your HTML readers. Use as much text as you want.
<body> <!--Comments for your HTML readers. Use as much text as you want.--> </body>
Conditional Comments
Pug does not have any special syntax for conditional comments. (Conditional comments are a peculiar method of adding fallback markup for old versions of Internet Explorer.)
However, since all lines beginning with <
are treated as plain text, normal HTML-style conditional comments work just fine.
doctype html <!--[if IE 8]> <html lang="en" class="lt-ie9"> <![endif]--> <!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]--> body p Supporting old web browsers is a pain. </html>
<!DOCTYPE html> <!--[if IE 8]> <html lang="en" class="lt-ie9"> <![endif]--> <!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]--> <body> <p>Supporting old web browsers is a pain.</p> </body> </html>
© Pug authors
Licensed under the MIT license.
https://pugjs.org/language/comments.html