Wikifunctions:MediaWiki parser functions
![]() |
This page is currently a draft. More information pertaining to this may be available on the talk page. Translation admins: Normally, drafts should not be marked for translation. |
Functions which have similar semantics to Wikitext parser functions (a.k.a. magic words) and templates used across wikis.
MediaWiki builtins
{{urlencode:x:y/z á é|QUERY}}
(produces |
— |
{{urlencode:x:y/z á é|WIKI}}
(produces |
10761
(produces |
{{urlencode:x:y/z á é|PATH}}
(produces |
10608
(matches) |
{{anchorencode:x y z á é}}
(produces |
— |
{{formatnum:987654321.654321}} | 14280 |
{{formatnum:987654321.654321|NOSEP}} | — |
{{formatnum:৯৮,৭৬,৫৪,৩২১.৬৫৪৩২১|R}} | — |
{{#formatdate:25 dec 2009|ymd}}
(produces |
— |
{{#formatdate:dec 25,2009|dmy}}
(produces |
20773
(produces |
{{#formatdate:2009-12-25|mdy}}
(produces |
20782
(produces |
{{#formatdate:2009 dec 25|ISO 8601}}
(produces |
21360
(produces |
{{lc:DATA CENTER}} | 10047 |
{{lcfirst:DATA center}} | — |
{{uc:text transform}} | 10018 |
{{ucfirst:text tRAnSFORM}} | — |
{{padleft:xyz|5|abc}} | 14770 |
{{padright:xyz|5|abc}} | 10108 |
{{#language:ar|en}}
(converts code for a language to that language's name in some other language) |
composition of 860 with 21329
(convert language codes to objects, then use those to look up the name) |
{{#bcp47:sr-ec}} | — |
{{#dir:en}} | — |
{{PLURAL:0|is|are}}
(chooses from given list of declensions based on variable) |
use the relevant function 11218, 11548, etc.
(chooses from given list of declensions based on variable) |
{{GRAMMAR:elative|wiki}}
(looks up the relevant declension for the given case) |
19530
(declines any lexeme into the relevant form, as a string, based on the given feature) |
{{GENDER:Username|male text|female text|text for unspecified}}
(chooses from given list of declensions based on some editor's gender setting) |
19530 if it's encoded that way on Wikidata, else something like 19601
(chooses from Wikidata forms or given list of declensions based on variable) |
Extension:ParserFunctions
MediaWiki | Function |
---|---|
{{#expr:}} | N/A; rewrite expression as a composition of logical and arithmetic functions, such as 13689 and 19708 |
{{#if:}} | 10083 |
{{#ifeq:}} | compose 802 with 866 |
{{#ifexpr:}} | N/A per {{#expr:}} |
{{#switch:}} | — |
{{#time:}} | — |
{{#len:}} | 11040 |
{{#pos:}} | — |
{{#rpos:}} | — |
{{#sub:}} | — |
{{#count:}} | 14450 |
{{#replace:}} | — |
{{#explode:}} | — |
{{#urldecode:}} | 10774 (imperfect match) |
Module:String
These are the alternate string manipulation set used on WMF wikis, where $wgPFEnableStringFunctions
is disabled. They mostly cover the same functionality as the ones from ParserExtensions but with different names and/or parameter semantics.
MediaWiki | Function |
---|---|
{{#invoke:String|len|target_string}} | 11040 |
{{#invoke:String|sub|target_string|start_index|end_index}} | — |
{{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}} | — |
{{#invoke:String|pos|target_string|index_value}} | — |
{{#invoke:String|find|source_string|target_string|start_index|plain_flag}} | — |
{{#invoke:String|replace|source_str|pattern_string|replace_string|replacement_count|plain_flag}} | — |
{{#invoke:String|rep|source|count}} | 12624 |
{{#invoke:String|escapePattern|pattern_string}} | — |
{{#invoke:String|count|source_str|pattern_string|plain_flag}} | 14450 |
{{#invoke:String|join|separator|string1|string2|...}} | 12899 |
Other English Wikipedia templates
MediaWiki | Function |
---|---|
{{ordinal|321}} | 14531 |
{{P1|a}} | 801 |
{{P1|a|b}} | 10265, 821, 811 |
{{P2|a|b}} | 10298, 822, 16360 |