Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support a non-html comment in markup #12035

Open
msmith-techempower opened this issue Jun 14, 2024 · 4 comments
Open

Support a non-html comment in markup #12035

msmith-techempower opened this issue Jun 14, 2024 · 4 comments
Milestone

Comments

@msmith-techempower
Copy link

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
Copy link
Member

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.

@dummdidumm dummdidumm added this to the 5.x milestone Jun 17, 2024
@Conduitry
Copy link
Member

I just spent way too long digging up #5213. One of the things that was requested in the past (which we said no to) was to be able to comment out specific attributes/props on an element/component. Have you thought about where you'd want to allow {/* ... */} to happen in the file? If that's only going to be allowed in certain places, I bet someone's going to ask why, and we should have a good answer for them.

@dummdidumm
Copy link
Member

I would allow it everywhere where {undefined} is allowed and treat it as shorthand for that

@roycrippen4
Copy link

Currently {undefined} is valid syntax everywhere in a .svelte file except inside of a style tag and html/component attributes. Does that mean the ability to comment out an attribute is not planned since {undefined} is not allowed within the list of attributes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants