This site is supported by donations to The OEIS Foundation.
Template:Error/doc
The {{error}} OEIS Wiki metatemplate returns a state of error (with HTML attribute class="error"
given to one of four choices of HTML tags, recognized as such by the wiki parser function extension
#iferror), and optionally a user-friendly error message text (in bold red by default).
Contents
Usage
{{#iferror: warning | {{no}} An error! | {{yes}} Not an error! }}
{{#iferror: error | {{no}} An error! | {{yes}} Not an error! }}
{{warning}}
This is a warning! {{#iferror: {{warning}} | {{no}} An error! | {{yes}} Not an error! }}
{{error}}
An error occurred! {{#iferror: {{error}} | {{no}} An error! | {{yes}} Not an error! }}
{{warning| A typical warning: You're lucky! }}
A typical warning: You're lucky! {{#iferror: {{warning| A typical warning: You're lucky! }} | {{no}} An error! | {{yes}} Not an error! }}
{{error| A typical error: Too bad! }}
A typical error: Too bad! {{#iferror: {{error| A typical error: Too bad! }} | {{no}} An error! | {{yes}} Not an error! }}
With parser function: {{#expr: 9+3 }}
12 {{#iferror: {{#expr: 9+3 }} | {{no}} An error! | {{yes}} Not an error! }}
With parser function: {{#expr: Foo }}
Expression error: Unrecognized word "foo". {{#iferror: {{#expr: Foo }} | {{no}} An error! | {{yes}} Not an error! }}
Tag option
The HTML tag to contain the error message can be given through the tag
parameter, but it will only accept div
, p
, span
, and strong
, since those are the only tags recognized by the #iferror
parser function. It defaults to strong
, the tag generated by e.g. the #expr
parser function. To prevent the use of the strong
default tag, use one of the other tags, e.g. tag = span
.
{{error|A typical error demo (default tag: strong)}} A typical error demo (default tag: strong) {{error|An exemplary error demo (strong tag)|tag = strong}} An exemplary error demo (strong tag) {{error|An exemplary error demo (span tag)|tag = span}} An exemplary error demo (span tag) {{error|An exemplary error demo (p tag)|tag = p}} An exemplary error demo (p tag)
{{error|An exemplary error demo (div tag)|tag = div}} An exemplary error demo (div tag)
Code
<noinclude>{{documentation}}</noinclude><includeonly><{{#switch: {{lc: {{{tag|}}} }} | div = div | p = p | span = span | #default = strong }} class="error">{{{message|{{{1|An error occurred!}}}}}}</{{#switch: {{lc: {{{tag|}}} }} | div = div | p = p | span = span | #default = strong }}></includeonly>
Code suggestion for {{if error}}
If we ever need a {{if error}} template, here's the code suggestion:
<noinclude>{{Documentation}}</noinclude><includeonly><!-- -->{{#if: {{#pos: {{{1|}}} | class{{=}}"error" }} | {{{2|}}} | {{{3|}}} }}</includeonly>
Tests:
:{{#if: {{#pos: {{warning}} | class{{=}}"error" }} | {{yes}} Error! | {{no}} No error. }} :{{#if: {{#pos: {{error}} | class{{=}}"error" }} | {{yes}} Error! | {{no}} No error. }}
yields
- No error.
- Error!
See also
- {{error}} to return an error message and a state of error (with HTML attribute
class="error"
) - {{if error}} to return different values depending on whether a state of error (with HTML attribute
class="error"
) is given within its first argument (see Code suggestion for{{if error}}
) -
#iferror
parser function extension (cf. MediaWiki external link below)
- {{warning}} to return a warning message and a state of warning (with HTML attribute
class="warning"
) - {{if warning}} to return different values depending on whether a state of warning (with HTML attribute
class="warning"
) is given within its first argument (see Code suggestion for{{if warning}}
) - There is no
#ifwarning
parser function extension, but the above suggested template may be implemented for that purpose.