Syntax for ignored comments #469
theoephraim
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just ran across some very unexpected behaviour around html comments in templates.
Basically if there is a comment at the root of the component (either before or after an actual node) then it treats the component as a multi-root component, which breaks things like using a template ref to get to the component's root.
There is some discussion about how to handle comments in general here, but I wanted to bring up a different related idea which might also help.
I would imagine the majority of comments in templates are simply notes for devs, and are never required or even desired in the rendered HTML. There are for sure cases where the comments are deliberate and you want them preserved, but I'd say that's the exception, not the rule.
I'm suggesting introducing some new syntax for template comments that will be totally ignored during compilation.
Pug has a similar feature with one style of comments being preserved in the rendered output:
Perhaps there is something similar we could do where we introduce a slightly modified syntax which signals to the compiler to totally drop it. Something like:
While I'd love a more terse single line comment style in vue templates only (something like
<// single line comment woohoo
). I imagine getting that built into all the IDE tooling would be a considerable lift versus something that is compatible with the existing/standard HTML comments.Beta Was this translation helpful? Give feedback.
All reactions