pugjs / pug

Pug – robust, elegant, feature rich template engine for Node.js
https://pugjs.org
21.64k stars 1.96k forks source link

Partial compilation of comment content #3236

Open kylekatarnls opened 4 years ago

kylekatarnls commented 4 years ago

Pug Version: pugjs.org

Input Pug

//
  p.
    go to #[a(href='') page]

Expected HTML

According to https://pugjs.org/language/comments.html

They act sort of like markup tags, producing HTML comments in the rendered page.

I would expect:

<!--<p>go to <a href="">page</a></p>-->

Actual HTML

p is not compiled, while interpolation is:

<!--p.
  go to <a href="">page</a>-->

I would appreciate some kind of explanation if this is the expected behavior.

Thanks,

Relates to https://github.com/phug-php/phug/issues/69

ForbesLindesay commented 4 years ago

This is intended behaviour for buffered comments. Use //- for an un-buffered comment (https://pugjs.org/language/comments.html)

kylekatarnls commented 4 years ago

This link is the one I came from and mentionned in my original post. I think you don't get my point. The question is: why the interpolation is compiled but not p?

ForbesLindesay commented 4 years ago

Ah, that's a fair point. I guess this is a little bit inconsistent.

kylekatarnls commented 4 years ago

I guess it's not expected to be compiled because it's only in multiline comments:

- foo = 9

// Foo #{foo}
// Foo #[a(href='') page]

//
  p.
    go to #[a(href='') page]

Only the last comment produces <a href="">