This site is supported by donations to The OEIS Foundation.

Template:Warning/doc

From OeisWiki
Jump to: navigation, search

This documentation subpage contains instructions, categories, or other information for Template:Warning. [<Edit> Template:Warning]

[⧼Purge⧽ Template:Warning/doc]

The {{warning}} OEIS Wiki metatemplate returns a state of warning (with HTML attribute class="warning" given to one of four choices of HTML tags, and optionally a user-friendly warning message text (in italic orange by default).

Usage

{{#iferror: warning | {{no}} An error! | {{yes}} Not an error! }} Green tickY Not an error!
{{#iferror: error | {{no}} An error! | {{yes}} Not an error! }} Green tickY Not an error!
 
{{warning}} This is a warning!
{{#iferror: {{warning}} | {{no}} An error! | {{yes}} Not an error! }} Green tickY Not an error!
 
{{error}} An error occurred!
{{#iferror: {{error}} | {{no}} An error! | {{yes}} Not an error! }} Red crossY 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! }} Green tickY 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! }} Red crossY An error!
 
With parser function: {{#expr: 9+3 }} 12
{{#iferror: {{#expr: 9+3 }} | {{no}} An error! | {{yes}} Not an error! }} Green tickY Not an error!
 
With parser function: {{#expr: Foo }} Expression error: Unrecognized word "foo".
{{#iferror: {{#expr: Foo }} | {{no}} An error! | {{yes}} Not an error! }} Red crossY An error!

Tag option

The HTML tag to contain the warning message can be given through the tag parameter, but it will only accept div, p, span and strong. It defaults to span. To prevent the use of the span default tag, use one of the other tags, e.g. tag = p.

{{warning|A typical warning demo (default tag: span)}} A typical warning demo (default tag: span)
{{warning|An exemplary warning demo (span tag)|tag = span}} An exemplary warning demo (span tag)
{{warning|An exemplary warning demo (strong tag)|tag = strong}} An exemplary warning demo (strong tag)
{{warning|An exemplary warning demo (p tag)|tag = p}}

An exemplary warning demo (p tag)

{{warning|An exemplary warning demo (div tag)|tag = div}}
An exemplary warning demo (div tag)

Code

<noinclude>{{documentation}}</noinclude><includeonly>''<{{#switch: {{lc: {{{tag|}}} }}
| div = div
| p = p
| strong = strong
| #default = span
}} class="warning" style="color: orange; font-size: 1.25em;">{{{message|{{{1|This is a warning!}}}}}}</{{#switch: {{lc: {{{tag|}}} }}
| div = div
| p = p
| strong = strong
| #default = span
}}>''</includeonly>

Code suggestion for {{if warning}}

If we ever need a {{if warning}} template, here's the code suggestion:

<noinclude>{{Documentation}}</noinclude><includeonly><!--
-->{{#if: {{#pos: {{{1|}}} | class{{=}}"warning" }} 
| {{{2|}}} 
| {{{3|}}}
}}</includeonly>

Tests:

:{{#if: {{#pos: {{warning}} | class{{=}}"warning" }} 
| {{yes}} Warning! 
| {{no}} No warning.
}}
:{{#if: {{#pos: {{error}} | class{{=}}"warning" }} 
| {{yes}} Warning! 
| {{no}} No warning.
}}

yields

Green tickY Warning!
Red crossY No warning.

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.

Interwiki links