在Pug(Jade)中发表评论?

sid*_*son 26 pug

你如何阻止Pug模板引擎中的注释代码?

我知道如何评论一条线:

//-doesn't show
Run Code Online (Sandbox Code Playgroud)

但我不想写这样的完整HTML评论:

<!--
    no show
-->
Run Code Online (Sandbox Code Playgroud)

Dan*_*ong 52

//-
    Just indent the comment
    like normal elements
Run Code Online (Sandbox Code Playgroud)

只需缩进你的评论,就像你做其他元素一样.

请注意,您的缩进是正确的,或者您可能会发表超出预期的评论.

  • 但是如何注释元素属性呢? (2认同)

Zaw*_*wad 6

官方文档

https://pugjs.org/language/comments.html#block-comments


缓冲评论-评论将出现在渲染的 HTML 中

//
    Comments for your HTML readers.
    Use as much text as you want.
Run Code Online (Sandbox Code Playgroud)


无缓冲评论-评论不会出现在渲染的 HTML 中

//-
    Comments for your template writers.
    Use as much text as you want.
Run Code Online (Sandbox Code Playgroud)