Template:Void/doc: Difference between revisions

shortcuts: {{^}} {{X0}} {{Null}}
From wikiNonStop
Content added Content deleted
m (→‎Alternatives: clean up links to Meta, replaced: m:Help → Help)
 
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
{{Template shortcut|^|X0|Null}}
{{High-use}}
This template does nothing visually. Technically, it throws away its parameters and outputs the null string.
This template does nothing visually. Technically, it throws away its parameters and outputs the null string.


It is useful for programming advanced templates, and is often used within a template to the right of an equals sign. It may also be used in a template to disambiguate parsing of braces.
It is useful for programming advanced templates, and is often used within a template to the right of an equals sign. It may also be used in a template to disambiguate parsing of braces.


It can also be used to temporarily disable code, and unlike "commenting out" with <syntaxhighlight lang=html inline><!-- --></syntaxhighlight>, it nests. This means that <code><nowiki>{{void|foo {{void|bar}} baz}}</nowiki></code> is valid, whereas <syntaxhighlight lang=html inline><!-- foo <!-- bar --> baz --></syntaxhighlight> will produce <code><!-- foo <!-- bar --> baz --></code>.
It can also be used to temporarily disable code. Unlike "[[commenting out]]" using [[HTML comment|HTML]] <code><nowiki><!-- --></nowiki></code>, it nests. This means that <code><nowiki>{{void|foo {{void|bar}} baz}}</nowiki></code> is valid, whereas <code><nowiki><!-- foo <!-- bar --> baz --></nowiki></code> will produce <code><!-- foo <!-- bar --> baz --></code>.


It provides a particularly concise way of temporarily disabling ''templates'', by prefixing them with <code>^|</code>, so the template name becomes the (ignored) first unnamed parameter. For example, suppose you have a page {{tlx|Under construction}} for several days, and wish to change that to {{tlx|In use}} during active editing sessions. Rather than delete the unused template, you can leave both templates in the wikisource and change from <code><nowiki>{{^|In use|...}}{{Under construction|...}}</nowiki></code> to <code><nowiki>{{In use|...}}{{^|Under construction|...}}</nowiki></code>.
It provides a particularly concise way of temporarily disabling ''templates'', by prefixing the template name with <code>^|</code>, making the template name become the (ignored) first unnamed parameter. For example, suppose you have a page {{tlx|Under construction}} for several days, and wish to change that to {{tlx|In use}} during active editing sessions. Rather than delete the unused template, you can leave both templates in the wikitext and change from <code><nowiki>{{^|In use|...}}{{Under construction|...}}</nowiki></code> to <code><nowiki>{{In use|...}}{{^|Under construction|...}}</nowiki></code>.


Another possible application would be to temporarily disable an infobox on an article page while a problem with the infobox template itself is resolved.
Another possible application would be to temporarily disable an infobox on an article page while a problem with the infobox template itself is resolved.

A deeper no-op is <code><nowiki>{{subst:void|foobar}}</nowiki></code> or <code><nowiki>{{subst:^|foobar}}</nowiki></code>. It disappears completely upon saving.


==Alternatives==
==Alternatives==
It's also possible to use <code><nowiki>{{ns:0}}</nowiki></code>, the empty/void/null string for the main [[Help:Namespace|namespace]].
{{Tlx|Null}} also redirects here. It is also possible to use {{tlc|ns:0}}, the empty/void/null string for the main [[m:Help:Namespace|namespace]].


It can be used in place of {{tag|nowiki|single}} to break character sequence parsing, for example <code><nowiki>{{nowrap|{''a''}{{null}}}}</nowiki></code> to force the first closing brace to be treated as part of the template parameter instead of as the end of the template expression.
It can be used in place of {{xtag|nowiki|s}} to break character sequence parsing, for example {{tlx|nowrap|<nowiki>{''a''}</nowiki>{{tl|null}}}} to force the first closing brace to be treated as part of the template parameter instead of as the end of the template expression.


== TemplateData ==
==TemplateData==
{{TemplateData header}}
{{TemplateData header}}
<TemplateData>{"description":"A template to show the null string, i.e. nothing. Any parameters are accepted and ignored.","params":{}}</TemplateData>
<TemplateData>

{"description": {
==See also==
"en": "A template to show the null string, i.e. nothing. Any parameters are accepted and ignored.",
*{{tl|0}}
"cs": "Šablona pro zobrazení nulového řetězce, tedy nic. Všechny parametry jsou přijímány a ignorovány."
* [[Template:Nothing]] – a template that displays an invisible HTML tag
},
* [[Template:Text]] – a template that just displays its first parameter unchanged.
"params": {
}
}
</TemplateData>


<includeonly>{{Sandbox other||
<includeonly>{{Sandbox other||
[[Category:Formatting templates]]
[[Category:Hiding templates]]
[[Category:Templates with no visible output]]
}}</includeonly>
}}</includeonly>

Revision as of 19:30, 13 August 2024

This template does nothing visually. Technically, it throws away its parameters and outputs the null string.

It is useful for programming advanced templates, and is often used within a template to the right of an equals sign. It may also be used in a template to disambiguate parsing of braces.

It can also be used to temporarily disable code. Unlike "commenting out" using HTML <!-- -->, it nests. This means that {{void|foo {{void|bar}} baz}} is valid, whereas <!-- foo <!-- bar --> baz --> will produce baz -->.

It provides a particularly concise way of temporarily disabling templates, by prefixing the template name with ^|, making the template name become the (ignored) first unnamed parameter. For example, suppose you have a page {{Under construction}} for several days, and wish to change that to {{In use}} during active editing sessions. Rather than delete the unused template, you can leave both templates in the wikitext and change from {{^|In use|...}}{{Under construction|...}} to {{In use|...}}{{^|Under construction|...}}.

Another possible application would be to temporarily disable an infobox on an article page while a problem with the infobox template itself is resolved.

A deeper no-op is {{subst:void|foobar}} or {{subst:^|foobar}}. It disappears completely upon saving.

Alternatives

{{Null}} also redirects here. It is also possible to use {{ns:0}}, the empty/void/null string for the main namespace.

It can be used in place of <nowiki /> to break character sequence parsing, for example {{nowrap|{''a''}{{Null }}}} to force the first closing brace to be treated as part of the template parameter instead of as the end of the template expression.

TemplateData

This is the TemplateData documentation for this template used by VisualEditor and other tools.

Void

A template to show the null string, i.e. nothing. Any parameters are accepted and ignored.

Template parameters

ParameterDescriptionTypeStatus
No parameters specified

See also