Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Error/doc: Difference between revisions

Template page
m tweak
c/e
 
(29 intermediate revisions by 20 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata -->
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
{{Lua|Module:Error}}
{{TemplateBox
| 1 = 1
| 1label-en = message
| 1d-en = The error message to display
| 1aliases = message
| 1stat = required
| 1type = content
 
| 2 = tag
| 2label-en = tag
| 2d-en = The HTML tag to wrap the error message in; one of “strong”, “span”, “div” and “p”
| 2def  = strong
| 2stat = optional-
| 2type = line
 
| name = error
| desc-en = The template returns a ''state of error'' (recognized as such by a wiki [[Help:Parser function|parser function]]), and an ''error message text'' in red (visible for the user). Used in other templates to both
| desc-td-en = The template returns a state of error (recognized as such by a wiki parser function), and an error message text in red (visible for the user).
| namespace = template
| usergroup = all
 
| seealso =
* [[Help:Parser function]]
* [[mw:Help:Extension:ParserFunctions##iferror:]]
* {{tl|Fact disputed}}
 
| i18n-method = -
 
| print = line
| useTemplateData = only
}}


=== Usage ===
=== Usage ===
Create a standard parser function error message.
* {{tlx|error|An exemplary error}} → {{error|An exemplary error}}
 
* Compare, used in a Parser Function: <code><nowiki>{{#expr:Foo}}</nowiki></code> → {{#expr:Foo}}
* {{tlx|error|An examplary error}} → {{error|An examplary error}}
* <code><nowiki>{{#iferror:{{error|Foo}} | DFD | FDD }}</nowiki></code> → {{#iferror:{{error|Foo}} | DFD | FDD }} ''<small>{color green or red)</small>''
* {{tlx|error|An examplary error span|3=tag=span}} → {{error|An examplary error div|tag=span}}
===Tag option===
* Compare: <nowiki>{{#expr:Invalid}}</nowiki> → {{#expr:Foo}}
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 <code>#iferror</code> parser function. It defaults to <code>strong</code>, the tag generated e.g. by <code>#expre</code>. To prevent <code>strong</code> message, use one of the other tags, e.g. <code>tag=span</code>.
* <nowiki>{{#iferror:{{error|Foo}} | {{y}} | {{n}} }}</nowiki> → {{#iferror:{{error|Foo}} | {{y}} | {{n}} }}


<includeonly>
* ABC {{tlx|error|An exemplary error demo no tag (default)}} XYZ → ABC {{error|An exemplary error demo no tag (default)}} XYZ
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
* ABC <nowiki>{{error|An exemplary error demo span|tag=span}}</nowiki> XYZ → ABC {{error|An exemplary error demo span|tag=span}} XYZ
[[Category:Wikipedia metatemplates|{{PAGENAME}}]]
* ABC <nowiki>{{error|An exemplary error demo div|tag=div}}</nowiki> XYZ → ABC {{error|An exemplary error demo div|tag=div}} XYZ
</includeonly>
* ABC <nowiki>{{error|An exemplary error demo p|tag=p}}</nowiki> XYZ → ABC {{error|An exemplary error demo p|tag=p}} XYZ
* ABC <nowiki>{{error|An exemplary error demo strong|tag=strong}}</nowiki> XYZ → ABC {{error|An exemplary error demo strong|tag=strong}} XYZ
<includeonly>{{Sandbox other||
<!-- Categories below this line; interwikis at Wikidata -->
[[Category:Error message templates| ]]
}}</includeonly>

Latest revision as of 08:51, 1 September 2025

The template returns a state of error (recognized as such by a wiki parser function), and an error message text in red (visible for the user). Used in other templates to both

Usage

{{error |1= }}

Template parameters

<templatedata>JSON</templatedata> ./. {{TemplateBox}}
TemplateData

TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard.


Existing template documentation
At Wikimedia Commons, it is recommended to use {{TemplateBox}} with either ‎useTemplateData=1 or ‎useTemplateData=only on the ‎/doc subpage and transcluding it with {{Documentation}} into the template. ‎<nowiki>-tags can be wrapped around the arguments, if required, to avoid templates being expanded.

Newly created template documentation and imports
Another option, especially for imported templates, or for users with JSON experience, is placing raw ‎<templatedata>-tags into the Wikitext of the template, as described in various Wikipediae.


Wikipedia's help about TemplateDataCommons-specific information

The template returns a state of error (recognized as such by a wiki parser function), and an error message text in red (visible for the user).

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
message1 message

The error message to display

Contentrequired
tagtag

The HTML tag to wrap the error message in; one of “strong”, “span”, “div” and “p”

Default
strong
Lineoptional

Additional information

The template is intended to be used in the following namespaces: the Template namespace

The template is intended to be used by the following user groups: all users

See also

Localization

This template is not intended to be localized.

Usage

  • {{error|An exemplary error}} → An exemplary error
  • Compare, used in a Parser Function: {{#expr:Foo}}Expression error: Unrecognized word "foo".
  • {{#iferror:{{error|Foo}} | DFD | FDD }} → DFD {color green or red)

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 #expre. 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
Cookies help us deliver our services. By using our services, you agree to our use of cookies.