Difference between revisions of "Template:Error/doc"

From MansunWiki
Jump to: navigation, search
(Created page with "{{Documentation subpage}} {{lua|Module:Error}} <!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> This meta template returns a ''state of error'' (recog...")
(No difference)

Revision as of 12:37, 16 July 2015

Template: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

  • {{error|An exemplary error}} → {{#invoke:Error|error|An exemplary error|tag=}}
  • {{error|message=An exemplary error}} → {{#invoke:Error|error|An exemplary error|tag=}}
  • Compare, used in a Parser Function: {{#expr:Foo}}Expression error: Unrecognised word "foo".
  • {{#iferror:{{error|Foo}} | {{y}} | {{n}} }}Red XN

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 {{#invoke:Error|error|An exemplary error demo no tag (default)|tag=}} XYZ
  • ABC {{error|An exemplary error demo span|tag=span}} XYZ → ABC {{#invoke:Error|error|An exemplary error demo span|tag=span}} XYZ
  • ABC {{error|An exemplary error demo div|tag=div}} XYZ → ABC {{#invoke:Error|error|An exemplary error demo div|tag=div}} XYZ
  • ABC {{error|An exemplary error demo p|tag=p}} XYZ → ABC {{#invoke:Error|error|An exemplary error demo p|tag=p}} XYZ
  • ABC {{error|An exemplary error demo strong|tag=strong}} XYZ → ABC {{#invoke:Error|error|An exemplary error demo strong|tag=strong}} XYZ

Template data

<TemplateData> {

       "description": "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)",
       "params": {
               "1": {
                       "label": "Message",
                       "description": "Error message text in red",
                       "type": "string",
                       "required": false
               },
               "tag": {
                       "label": "Tag",
                       "description": "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",
                       "type": "string",
                       "default": "strong",
                       "required": false
               }
       }

} </TemplateData>

See also