Help:Comment tags

From mediawiki.org
PD Note: When you edit this page, you agree to release your contribution under the CC0. See Public Domain Help Pages for more info. PD

Comments tags and the text between them are deleted when rendering the wikitext. If comments are separated by single newlines, the newlines before, between, and after count as one. If separated by two newlines, this rule applies separately for each sequence.

Wikitext Rendering
x<!--This is a comment-->y

x
<!--This is a comment-->y

x <!--This is a comment
-->y

x<!--This is a comment-->
y

x
<!--This is a comment-->
y

x<!--This is a comment-->
<!--This is a comment-->y

x
<!--This is a comment-->
<!--This is a comment-->y

x<!--This is a comment-->
<!--This is a comment-->
y

x
<!--This is a comment-->
<!--This is a comment-->
y

x<!--This is a comment--> <!--This is a comment-->y

x
<!--This is a comment--> <!--This is a comment-->y

x<!--This is a comment--> <!--This is a comment-->
y

x
<!--This is a comment--> <!--This is a comment-->
y


x<!--This is a comment-->

<!--This is a comment-->y

x
<!--This is a comment-->

<!--This is a comment-->y

x<!--This is a comment-->

<!--This is a comment-->
y

x
<!--This is a comment-->

<!--This is a comment-->
y
xy

x
y

x
y

x
y

x
y

x
y

x
y

x
y

x y

x
 y

x 
y

x
 
y


x

y

x

y

x

y

x

y

Using substitution[edit]

During the substitution process, comments in the original template or content can also be retained in the resulting wikitext. These comments serve as a record of how the content was produced and may include notes or explanations relevant to the template itself.

Sometimes, comments may be relevant only to the template and may not enhance understanding when included in the resulting wikitext.

When deciding whether to preserve comments during substitution, consider the clarity and readability of the wikitext, and whether the comments provide valuable context for editors working on the page.

Comment Preservation Options during Substitution[edit]

  • Always Preserve: Include comment tags directly within the template.
  • Don't Preserve: If you want to ensure that comments within a template are not preserved during substitution, you can enclose those comments within <noinclude> tags.
  • Control the Preservation: Instead of using regular comment tags, the Template:Void template is used to control comment preservation. By placing comments within the void template, they can be selectively included or excluded based on specific conditions.
For example
{{{{{|safesubst:}}}void|..}}
The comment replaces the dots.

Parameter tags within comment tags do not work, but they do within the void-method.

You can test this by using {{subst:Help:Comment tags/1|7}} and {{subst:Help:Comment tags/1|=|7}}, both substituting Help:Comment tags/1. The first removes the controlled comments, while the second does not.

See also[edit]