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.

  1. // just some paragraphs
  2. p foo
  3. p bar
  1. <!-- just some paragraphs-->
  2. <p>foo</p>
  3. <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.

  1. //- will not output within markup
  2. p foo
  3. p bar
  1. <p>foo</p>
  2. <p>bar</p>

Block Comments

Block comments work, too:

  1. body
  2. //-
  3. Comments for your template writers.
  4. Use as much text as you want.
  5. //
  6. Comments for your HTML readers.
  7. Use as much text as you want.
  1. <body>
  2. <!--Comments for your HTML readers.
  3. Use as much text as you want.-->
  4. </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.

  1. doctype html
  2. <!--[if IE 8]>
  3. <html lang="en" class="lt-ie9">
  4. <![endif]-->
  5. <!--[if gt IE 8]><!-->
  6. <html lang="en">
  7. <!--<![endif]-->
  8. body
  9. p Supporting old web browsers is a pain.
  10. </html>
  1. <!DOCTYPE html>
  2. <!--[if IE 8]>
  3. <html lang="en" class="lt-ie9">
  4. <![endif]-->
  5. <!--[if gt IE 8]><!-->
  6. <html lang="en">
  7. <!--<![endif]-->
  8. <body>
  9. <p>Supporting old web browsers is a pain.</p>
  10. </body>
  11. </html>