Template:Error/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (→‎Tracking category: Bullet point)
(→‎Usage: - Added nocat for examples.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Doc/subpage}}
<!-- Please place categories where indicated at the bottom of this page -->
<!-- Please place categories where indicated at the bottom of this page -->


Line 5: Line 5:


== Usage ==
== Usage ==
* {{tlx|error|An exemplary error}} → {{error|An exemplary error}}
* {{tlx|error|An exemplary error}} → {{error|An exemplary error|nocat=1}}
* {{tlx|error|message{{=}}An exemplary error}} → {{error|message=An exemplary error}}
* {{tlx|error|message{{=}}An exemplary error}} → {{error|message=An exemplary error|nocat=1}}
* Compare, used in a Parser Function: <code><nowiki>{{#expr:Foo}}</nowiki></code> → {{#expr:Foo}}
* Compare, used in a Parser Function: <code><nowiki>{{#expr:Foo}}</nowiki></code> → {{#expr:Foo|nocat=1}}
* <code><nowiki>{{#iferror:{{error|Foo}} | {{y}} | {{n}} }}</nowiki></code> → {{#iferror:{{error|Foo}} | {{y}} | {{n}} }}
* <code><nowiki>{{#iferror:{{error|Foo}} | {{y}} | {{n}} }}</nowiki></code> → {{#iferror:{{error|Foo|nocat=1}} | {{y}} | {{n}} }}
 
* To prevent the the page from adding to the [[:Category:Pages with template errors]], use {{param|nocat}}.


=== Tag option ===
=== Tag option ===
The tag to contain the error message can be given through the <code>tag</code> parameter, but it will only accept <code>span</code>, <code>div</code>, <code>p</code>, and <code>strong</code>, since those are the only tags recognized by the {{pf|iferror}} parser function. It defaults to <code>strong</code>, the tag generated e.g. by {{pf|expr}}. To prevent <code>strong</code> message, use one of the other tags, e.g. <code>tag=span</code>.
The tag to contain the error message can be given through the <code>tag</code> parameter, but it will only accept <code>span</code>, <code>div</code>, <code>p</code>, and <code>strong</code>, since those are the only tags recognized by the {{pf|iferror}} parser function. It defaults to <code>strong</code>, the tag generated e.g. by {{pf|expr}}. To prevent <code>strong</code> message, use one of the other tags, e.g. <code>tag=span</code>.


* ABC {{tlx|error|An exemplary error demo no tag (default)}} XYZ → ABC {{error|An exemplary error demo no tag (default)}} XYZ
* ABC {{tlx|error|An exemplary error demo no tag (default)}} XYZ → ABC {{error|nocat=1|An exemplary error demo no tag (default)}} XYZ
* ABC {{tlx|error|An exemplary error demo span|tag{{=}}span}} XYZ → ABC {{error|An exemplary error demo span|tag=span}} XYZ
* ABC {{tlx|error|An exemplary error demo span|tag{{=}}span}} XYZ → ABC {{error|nocat=1|An exemplary error demo span|tag=span}} XYZ
* ABC {{tlx|error|An exemplary error demo div|tag{{=}}div}} XYZ → ABC {{error|An exemplary error demo div|tag=div}} XYZ
* ABC {{tlx|error|An exemplary error demo div|tag{{=}}div}} XYZ → ABC {{error|nocat=1|An exemplary error demo div|tag=div}} XYZ
* ABC {{tlx|error|An exemplary error demo p|tag{{=}}p}} XYZ → ABC {{error|An exemplary error demo p|tag=p}} XYZ
* ABC {{tlx|error|An exemplary error demo p|tag{{=}}p}} XYZ → ABC {{error|nocat=1|An exemplary error demo p|tag=p}} XYZ
* ABC {{tlx|error|An exemplary error demo strong|tag{{=}}strong}} XYZ → ABC {{error|An exemplary error demo strong|tag=strong}} XYZ
* ABC {{tlx|error|An exemplary error demo strong|tag{{=}}strong}} XYZ → ABC {{error|nocat=1|An exemplary error demo strong|tag=strong}} XYZ


== Tracking category ==
== Tracking category ==

Latest revision as of 00:50, 13 January 2024

Edit-copy.png
This is a documentation subpage for Template:Error.
Don't forget to purge the contents of the base page upon creating or editing this subpage.

This meta template returns a state of error (recognized as such by a wiki parser function), and optionally an error-message text in red (visible for the user). It is used by other templates to signal an error, for example invalid input, which can then either be displayed to the editor or caught and handled by other templates.

Usage

  • {{error|An exemplary error}}An exemplary error
  • {{error|message=An exemplary error}}An exemplary error
  • Compare, used in a Parser Function: {{#expr:Foo}}Expression error: Unrecognized word "foo".
  • {{#iferror:{{error|Foo}} | {{y}} | {{n}} }}Green tickY

Tag option

The tag to contain the error message can be given through the tag parameter, but it will only accept span, div, p, and strong, since those are the only tags recognized by the {{#iferror}} parser function. It defaults to strong, the tag generated e.g. by {{#expr}}. To prevent strong message, use one of the other tags, e.g. tag=span.

  • ABC {{error|An exemplary error demo no tag (default)}} XYZ → ABC An exemplary error demo no tag (default) XYZ
  • ABC {{error|An exemplary error demo span|tag=span}} XYZ → ABC An exemplary error demo span XYZ
  • ABC {{error|An exemplary error demo div|tag=div}} XYZ → ABC
    An exemplary error demo div
    XYZ
  • ABC {{error|An exemplary error demo p|tag=p}} XYZ → ABC

    An exemplary error demo p

    XYZ
  • ABC {{error|An exemplary error demo strong|tag=strong}} XYZ → ABC An exemplary error demo strong XYZ

Tracking category