// is a comment for the template's readers: it is left out of the HTML. //! is an HTML comment: it is written to the output. Both run to the end of their line.
zamn
// Only people reading the template see this.//! Everyone reading the page source sees this.p Hello
html
<!-- Everyone reading the page source sees this.--><p>Hello</p>
Everything after the marker is copied as written, including the space after it.
/* ... */ is left out of the HTML, and /*! ... */ is written as an HTML comment. A block comment can span lines and ends at the first */; block comments don't nest. Its content is not parsed, so it can hold anything, including lines that would be errors:
zamn
/* Not ready yet: a(href=base + "/docs") Docs*//*! Built by zamn */p Done
html
<!-- Built by zamn --><p>Done</p>
A block comment goes wherever a statement can start: on a line of its own, after a {, or after a child that ends with }:
zamn
div { /* the title */ h2 { | Title } /* the body */ p Body }
html
<div> <h2>Title</h2> <p>Body</p></div>
An unclosed block comment is an error (UNCLOSED_COMMENT).
"Toggle Line Comment" in VS Code writes //, so commenting out a line never puts it into the page. ESLint directives work as // comments in a Vue template:
Comments
//is a comment for the template's readers: it is left out of the HTML.//!is an HTML comment: it is written to the output. Both run to the end of their line.Everything after the marker is copied as written, including the space after it.
Block comments
/* ... */is left out of the HTML, and/*! ... */is written as an HTML comment. A block comment can span lines and ends at the first*/; block comments don't nest. Its content is not parsed, so it can hold anything, including lines that would be errors:A block comment goes wherever a statement can start: on a line of its own, after a
{, or after a child that ends with}:An unclosed block comment is an error (
UNCLOSED_COMMENT).In text
Inside text,
//and/*are just text, so links and paths need nothing special:Comments are not escaped: what you write after
//!or inside/*! */reaches the HTML as it is.In editors and linters
"Toggle Line Comment" in VS Code writes
//, so commenting out a line never puts it into the page. ESLint directives work as//comments in a Vue template: