WikiIndex:Parser functions: Difference between revisions

From WikiIndex
Jump to navigation Jump to search
No edit summary
 
(→‎switch: Fixes)
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''ParserFunction''' is a special kind of [[WikiIndex:Magic words|magic word]] that is most useful for templates.
A '''parser function''' is a special kind of [[WikiIndex:Magic words|magic word]] that is most useful for [[:Category:Templates|templates]].
__NOTOC__
{{TOC right}}
{{WikiIndex-stub}}
 
==List==
==List==
*[[#expr]]
*[[#expr]]
Line 10: Line 12:
*[[#switch]]
*[[#switch]]
*[[#time]]
*[[#time]]
==expr==
==expr==
coming soon.
coming soon.
==if==
==if==
Shows different values when entered.<br>
Shows different values when entered.<br>
Code:
;Code:
<pre>{{ #if: {{{value|}}} | what to show if activated | what to show if not }}</pre>
<pre>{{#if: {{{value|}}} | what to show if activated | what to show if not }}</pre>
Example:
;Example:
<pre>{{ #if: {{{1|}}} | The name of this site is {{{1}}}. | This site has an unknown name. }}</pre>
<pre>{{#if: {{{1|}}} | The name of this site is {{{1}}}. | This site has an unknown name. }}</pre>
Let's say this is included in the template ''[[Template:IfExample|ifExample]]''. If <nowiki>{{ifExample|WikiIndex}}</nowiki> is entered, "{{ifExample|WikiIndex}}" will show up because value was specified, as "WikiIndex". <nowiki>{{ifExample|not WikiIndex}}</nowiki> makes "{{ifExample|not WikiIndex}}", because value is specified, as "not WikiIndex". <nowiki>{{ifExample}}</nowiki> makes just "{{ifExample}}" because it was left blank.
Let's say this is included in the template ''[[Template:If example|if example]]''. If <code><nowiki>{{if example|WikiIndex}}</nowiki></code> is entered, '{{if example|WikiIndex}}' will show up because value was specified, as 'WikiIndex'. <code><nowiki>{{if example|not WikiIndex}}</nowiki></code> makes '{{if example|not WikiIndex}}', because value is specified, as 'not WikiIndex'. <code><nowiki>{{if example}}</nowiki></code> makes just '{{if example}}' because it was left blank.
 
==ifeq==
==ifeq==
coming soon.
coming soon.
==ifexist==
==ifexist==
coming soon.
coming soon.
==ifexpr==
==ifexpr==
coming soon.
coming soon.
==rel2abs==
==rel2abs==
coming soon.
coming soon.
==switch==
==switch==
Compares values.<br>
Compares values.<br>
Code:
;Code:
<pre>{{ #switch: value  
<pre>{{#switch:value
| value1 = what to show if value1 is entered  
|value1 = what to show if value1 is entered
| value2 = what to show if value2 is entered  
|value2 = what to show if value2 is entered
| what to show if something else is entered  
| |what to show if something else is entered
| #default = what to show if nothing is entered  
|#default = what to show if nothing is entered
}}</pre>
}}</pre>
Example:
;Example:
<pre>{{ #switch: {{{1}}}  
<pre>{{#switch:{{{1}}}
| a = argh  
|a = argh
| b = blah  
|b = blah
| c = cough  
|c = cough
| anything  
| |anything
| #default = nothing  
|#default = nothing
}}</pre>
}}</pre>
This is included in the template [[template:switchExample|switchExample]]. <nowiki>{{switchExample|a}}</nowiki> gives "{{switchExample|a}}" because a is entered. <nowiki>{{switchExample}}</nowiki> gives "{{switchExample}}", because the template was left blank. <nowiki>{{switchExample|d}}</nowiki> gives "{{switchExample|d}}", because d doesn't exist in the template.
This is included in the template [[Template:Switch example|switch example]]. <code><nowiki>{{switch example|a}}</nowiki></code> gives '{{switch example|a}}' because a is entered. <code><nowiki>{{switch example}}</nowiki></code> gives '{{switch example}}', because the template was left blank. <code><nowiki>{{switch example|d}}</nowiki></code> gives '{{switch example|d}}', because d doesn't exist in the template.
 
==time==
==time==
coming soon.
coming soon.
==See also==
*{{Mw|Help:Extension:ParserFunctions}} at [[MediaWiki.org]]
[[Category:WikiIndex]]
[[Category:Help]]

Latest revision as of 13:25, 11 January 2023

A parser function is a special kind of magic word that is most useful for templates.

This WikiIndex:Parser functions article is a WikiIndex 'stub'. If you are familiar with, and understand the WikiIndex policy system, you can help by expanding this WikiIndex stub article, thanks.  :-)

List[edit]

expr[edit]

coming soon.

if[edit]

Shows different values when entered.

Code
{{#if: {{{value|}}} | what to show if activated | what to show if not }}
Example
{{#if: {{{1|}}} | The name of this site is {{{1}}}. | This site has an unknown name. }}

Let's say this is included in the template if example. If {{if example|WikiIndex}} is entered, 'The name of this site is WikiIndex.' will show up because value was specified, as 'WikiIndex'. {{if example|not WikiIndex}} makes 'The name of this site is not WikiIndex.', because value is specified, as 'not WikiIndex'. {{if example}} makes just 'This site has an unknown name.' because it was left blank.

ifeq[edit]

coming soon.

ifexist[edit]

coming soon.

ifexpr[edit]

coming soon.

rel2abs[edit]

coming soon.

switch[edit]

Compares values.

Code
{{#switch:value
|value1 = what to show if value1 is entered
|value2 = what to show if value2 is entered
| |what to show if something else is entered
|#default = what to show if nothing is entered
}}
Example
{{#switch:{{{1}}}
|a = argh
|b = blah
|c = cough
| |anything
|#default = nothing
}}

This is included in the template switch example. {{switch example|a}} gives 'argh' because a is entered. {{switch example}} gives 'nothing', because the template was left blank. {{switch example|d}} gives 'nothing', because d doesn't exist in the template.

time[edit]

coming soon.

See also[edit]