Template:Error/doc
{{#ifeq:doc |doc
|
{{#ifeq:show |show
|
This is a documentation subpage for Template:Error{{#if:||.}} It may contain usage information, categories and other content that is not part of the original {{#if: |{{{text2}}} |{{#if: |{{{text1}}} |{{#ifeq:Template |User |template template page |{{#if:Template |template page|article}}}}}}}}. |
}}{{#if: | | {{#ifexist:Template:Error | [[Category:{{#switch:Template |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]] | }} }} | }}
This template is used on approximately 29,000 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
This template uses Lua: |
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[edit]
{{error|An exemplary error}}
→ An exemplary error{{error|message=An exemplary error}}
→ An exemplary error- Compare, used in a Parser Function:
{{#expr:Foo}}
→ {{#expr:Foo}} {{#iferror:{{error|Foo}} | {{y}} | {{n}} }}
→ {{#iferror:Foo | | Template:N }}
Tag option[edit]
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 {{#if:|}}{{{{
#switch: iferror
| expr | if | ifeq | iferror | ifexpr
| ifexist | rel2abs | switch | time
| titleparts = #iferror
| lc | uc | lcfirst | ucfirst | urlencode | anchorencode
| ns = iferror
| localurl | localurle | fullurl
| fullurle = iferror
| language = #iferror
| pagesincategory
| pagesincat = iferror
| section | section-x | section-h | lst | lstx | lsth = #iferror
| #default = iferror
}}{{
#if:
| Template:Colon
}}{{
#if:
| {{
#ifeq: |
| Template:Colon|
}}|{{{3}}}
}}{{
#if:
| {{
#ifeq: |
| Template:Colon|
}}{{
#ifeq: |
| |
}}|{{{4}}}
}}{{
#if:
| {{
#ifeq: |
| Template:Colon|
}}{{
#ifeq: |
| |
}}{{
#ifeq: |
| |
}}|{{{5}}}
}}}}{{#if:|
}} parser function. It defaults to strong
, the tag generated e.g. by {{#if:|}}{{{{
#switch: expr
| expr | if | ifeq | iferror | ifexpr
| ifexist | rel2abs | switch | time
| titleparts = #expr
| lc | uc | lcfirst | ucfirst | urlencode | anchorencode
| ns = expr
| localurl | localurle | fullurl
| fullurle = expr
| language = #expr
| pagesincategory
| pagesincat = expr
| section | section-x | section-h | lst | lstx | lsth = #expr
| #default = expr
}}{{
#if:
| Template:Colon
}}{{
#if:
| {{
#ifeq: |
| Template:Colon|
}}|{{{3}}}
}}{{
#if:
| {{
#ifeq: |
| Template:Colon|
}}{{
#ifeq: |
| |
}}|{{{4}}}
}}{{
#if:
| {{
#ifeq: |
| Template:Colon|
}}{{
#ifeq: |
| |
}}{{
#ifeq: |
| |
}}|{{{5}}}
}}}}{{#if:|
}}. 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 → ABCAn exemplary error demo divXYZ - ABC
{{error|An exemplary error demo p|tag=p}}
XYZ → ABCAn exemplary error demo p
XYZ - ABC
{{error|An exemplary error demo strong|tag=strong}}
XYZ → ABC An exemplary error demo strong XYZ
TemplateData[edit]
|=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AError%7CError%7CError%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|S|s}}ee a monthly parameter usage report] for {{#if:Error|Template:Error|this template}} in articles{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Error|its|this}} TemplateData}}.
|None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AError%7CError%7CError%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|P|p}}arameter usage report]{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Error|its|this}} TemplateData}}
|for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AError%7CError%7CError%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|P|p}}arameter usage report] for {{#if:Error|Template:Error|Template:Error}}{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Error|its|this}} TemplateData}}.
|#default=[1]{{#ifeq:{{safesubst:#switch: y |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Error|its|this}} TemplateData}} }}|This is the {{#if:|TemplateData|TemplateData}} for this template used by TemplateWizard, VisualEditor and other tools. {{#switch:
|=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AError%7CError%7CError%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|S|s}}ee a monthly parameter usage report] for {{#if:Error|Template:Error|this template}} in articles{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Error|its|this}} TemplateData}}.
|None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AError%7CError%7CError%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|P|p}}arameter usage report]{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Error|its|this}} TemplateData}}
|for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AError%7CError%7CError%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|P|p}}arameter usage report] for {{#if:Error|Template:Error|Template:Error}}{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Error|its|this}} TemplateData}}.
|#default=[2]{{#ifeq:{{safesubst:#switch: y |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Error|its|this}} TemplateData}} }}}}
TemplateData for Error
{{#switch:
{{#if: | {{{demospace}}} | {{#ifeq:Template|Template | template | other }} }}
| template = {{#if:{{#ifeq:doc|sandbox|1}}{{#ifeq:doc|doc|1}}||
}} | other | #default = }}
The 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)
Parameter | Description | Type | Status | |
---|---|---|---|---|
Message | 1 message | Error message text in red | String | suggested |
Tag | tag | The tag to contain the error message; 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
| String | optional |
See also[edit]