Difference between revisions of "Link"

From Shihad Wiki
Jump to: navigation, search
(Removing all content from page)
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
<small>'''Other languages:''' {{ParserFunctions}}</small>
 
{{h:h}}
 
{{sspp}}
 
{{shortcut|[[WM:PF]]}}
 
{{move|[[mw:Extension:ParserFunctions]]}}
 
{{extension
 
|name        = ParserFunctions
 
|image      =
 
|type        = Parser Extension
 
|maturity    = Stable
 
|mediawiki  = > 1.6.8
 
|version    = N/A
 
|update      = 2006-11-21
 
|description = A collection of [[Help:parser function|parser functions]] such as branching instructions and expression handler and time calculation unit.
 
}}
 
  
{{otheruses4|the MediaWiki extension '''ParserFunctions'''|parser functions in general|Help:Parser function}}
 
 
The [[w:MediaWiki|MediaWiki]] extension '''[[mw:Extension:ParserFunctions|ParserFunctions]]''' is a collection of [[Help:parser function|parser functions]] (note the difference between the name of the collection, and the general term). These parser functions have a hash character in front of the function name, so they typically have the syntax:
 
: {{ft|#functionname|<nowiki>argument 1 | argument 2 | argument 3...</nowiki>}}
 
 
==Functions==
 
The extension defines nine functions:
 
<tt>[[#.23expr:|expr]]</tt>,
 
<tt>[[#.23if:|if]]</tt>,
 
<tt>[[#.23ifeq:|ifeq]]</tt>,
 
<tt>[[#.23ifexist:|ifexist]]</tt>,
 
<tt>[[#.23ifexpr:|ifexpr]]</tt>,
 
<tt>[[#.23switch:|switch]]</tt>,
 
<tt>[[#.23time:|time]]</tt>,
 
<tt>[[#.23rel2abs:|rel2abs]]</tt>, and
 
<tt>[[#.23titleparts:|titleparts]]</tt>.
 
 
 
<h3 style="background: blue">#expr:</h3>
 
* syntax: {{ft|#News|expression}}
 
 
<h3 style="background: beige">#if:</h3>
 
* syntax:
 
*: {{ft|#if|<nowiki><condition string> | <code if true></nowiki>}}
 
*: {{ft|#if|<nowiki><condition string> | <code if true> | <code if false></nowiki>}}
 
 
The <code>if</code> function is an if-then-else construct. The condition is always true unless it is empty or whitespace-only. The code in the second argument is parsed if the condition is true, and the third argument is parsed if the condition is false (either or both may be blank, and the code-if-false argument can be omitted entirely).
 
 
The condition is evaluated as text, so mathematical expressions will always evaluate as true; to use expressions as conditions, see <tt>[[#.23ifexpr:|#ifexpr]]</tt>. It is not possible to distinguish between an undefined parameter in a template and a blank one (it is possible with <tt>[[#.23ifexpr:|#ifexpr]]</tt>).
 
 
Examples:
 
* {{ft|#if|<nowiki>foo | do if true | do if false</nowiki>}} = {{#if:foo| do if true | do if false}}
 
* {{ft|#if|<nowiki>0  | do if true | do if false</nowiki>}} = {{#if:0  | do if true | do if false}}
 
* {{ft|#if|<nowiki>    | do if true | do if false</nowiki>}} = {{#if:  | do if true | do if false}}
 
 
<h3 style="background: beige">#ifeq:</h3>
 
* syntax:
 
*: {{ft|#ifeq|<nowiki><text 1> | <text 2> | <code if equal></nowiki>}}
 
*: {{ft|#ifeq|<nowiki><text 1> | <text 2> | <code if equal> | <code if not equal></nowiki>}}
 
 
 
[[Category:Pages to be exported to MediaWiki.org]]
 

Latest revision as of 00:17, 3 March 2008