sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
77.45k stars 4.03k forks source link

Support a non-html comment in markup #12035

Open msmith-techempower opened 2 weeks ago

msmith-techempower commented 2 weeks ago

Describe the problem

Very often, I will build something out as a PoC first in a single Svelte component before proving out the concept and excising reusable sections to their own components. Often, this looks like starting with the piece I want to keep, and commenting out the remaining to test that the base stuff is working as expected, but if I have any html comments (which is the only way I am aware to comment on markup in Svelte) then IntelliSense will break when I try and comment around those html comments.

<!--
   ... 
  <!-- Actual comment that I want -->

  no end-comment-tag because it detected it in the above comment
  and even if it added it...
--> this is technically invalid html and throws an 'unexpected block closing tag' error

Describe the proposed solution

JSX supports this with simple block like {/* some comment */}, but I understand the mustache semantics are a little different in svelte.

Perhaps another type of decorator like {#comment The comment body} or something would be good? The compiler would strip these out at build time and they would be solely for the developers.

Importance

nice to have

dummdidumm commented 2 weeks ago

I would be ok with allowing {/* some comment */} (more generally allowing empty expressions like {} which would help language tools to give better suggestions). A special block for this would be way too much for such a niche use case.