Расширение:Расширения функций парсера

This page is a translated version of the page Parser function extensions and the translation is 31% complete.
Outdated translations are marked like this.

A "parser function" is a template-like construct that returns a value based on at least one unnamed parameter, separated from the function name by a colon [:]. There may be more parameters, as well; like those of ordinary templates, these additional parameters are each preceded by a "pipe" [|]. In the case of a hash character [#] at the start of the function name (which prevents collision with namespaces and interwiki prefixes), this may or may not be considered part of the name. If it is considered part of the name, the syntax is of the form

{{functionname: argument 1 | argument 2 | argument 3...}}
If the caller has no arguments to provide the parser function, then the form is simply {{functionname:}} or, when a hash character applies (as is normally the case) then the form is {{#functionname:}}. If the trailing colon is not supplied, then functionname is not recognized by the parser.

Arguments cannot directly contain "|" or "}}" except as part of the code of a template call, parser function call, variable, link or image, but they can contain them arbitrarily using a template, e.g., m:Template:!, or a parser function.

The code can specify whether the function name is case-sensitive.

The separation of the arguments from each other is with "|", and from the function name is with the first ":" The expansion of each of these pieces is standard, as in Special:ExpandTemplates (which is a good place to experiment, by the way, if you are learning this stuff) and is beyond the control of the parser function itself.

However, everything else can be different for each parser function, including:

  • whether an argument is just a value, or of the form parname = parvalue, or whatever
  • if applicable, whether parameter names are case-sensitive

Syntax prescribed by a parser function extension

In view of the above, it is advantageous to make an extension such that the syntax to be used in an argument does not contain the pipe character "|" or double braces (more specifically, double closing braces "}}" ). This, in spite of the fact that a pipe character would otherwise seem a suitable symbol for, e.g., a choice or union (see, e.g., [1]). Allowing such codes is harmless if an alternative code is also allowed, e.g. "\" for "|".

Таблица функций

расширение функция Версия MediaWiki
built-in lc 1.7+
built-in uc 1.7+
built-in lcfirst 1.7+
built-in ucfirst 1.7+
built-in urlencode 1.7+
built-in anchorencode 1.8+
built-in localurl 1.7+
built-in fullurl 1.7+
built-in #language 1.7+
built-in #special 1.9+
built-in #tag 1.12+
Функции парсера (usage ) #expr 1.19+
Функции парсера (usage ) #ifexpr 1.19+
Функции парсера (usage ) #if 1.19+
Функции парсера (usage ) #ifeq 1.19+
Функции парсера (usage ) #ifexist 1.19+
Функции парсера (usage ) #rel2abs 1.19+
Функции парсера (usage ) #titleparts 1.19+
Функции парсера (usage ) #switch 1.19+
Функции парсера (usage ) #time 1.19+
AddScriptCss #addscript Archived
Arrays #arraydefine 1.23+
Arrays #arraydiff 1.23+
Arrays #arrayindex 1.23+
Arrays #arrayintersect 1.23+
Arrays #arraymerge 1.23+
Arrays #arrayprint 1.23+
Arrays #arrayreset 1.23+
Arrays #arraysearch 1.23+
Arrays #arraysearcharray 1.23+
Arrays #arraysize 1.23+
Arrays #arrayslice 1.23+
Arrays #arraysort 1.23+
Arrays #arraytohash 1.23+
Arrays #arrayunion 1.23+
Arrays #arrayunique 1.23+
Arrays #hashtoarray 1.23+
Attachments #attach 1.31+
Attachments #exturl 1.31+
Babel #babel 1.30+
CSS #css 1.25+
Coordinate #coordinate Archived
Counter #+ 1.15+
Data #data Archived
Data #sort Archived
DynamicFunctions #arg Archived
DynamicFunctions #ip Archived
DynamicFunctions #rand Archived
DynamicFunctions #skin Archived
DynamicPageList (third-party) #dpl Archived
DynamicPageList3 #dpl 1.39+
ExpandAfter #expandafter (deprecated , see: #tag) Archived
ForeachFunction #foreachx Archived
ForeachFunction #foreachy Archived
HasCategory #ifhascat Archived
HideNamespace #hidens Archived
HideNamespace #unhidens Archived
ImageLink #img (old: #imagelink, deprecated ) Archived
Infobox Data Capture #dataentry Archived
Infobox Data Capture #listsplit Archived
InterWikiLinkManager #iwl Archived
KeyValue #keyvalue Archived
Labeled Section Transclusion #lst 1.25+
Labeled Section Transclusion #lstx 1.25+
Labeled Section Transclusion #lsth 1.25+
LoopFunctions #for 1.23+
LoopFunctions #foreach 1.25+
Циклы #while 1.25+
Циклы #dowhile 1.25+
Циклы #forargs 1.25+
Циклы #fornumargs 1.25+
Циклы #loop 1.25+
Maps #geocode 1.27+
Maps #display_map 1.27+
Maps #display_point 1.27+
Maps #coordinates 1.27+
Maps #distance 1.27+
MediaFunctions #media.. 1.23+
PageAfterAndBefore #pagebefore Archived
PageAfterAndBefore #pageafter Archived
PageAfterAndBefore #firstpage Archived
PageAfterAndBefore #lastpage Archived
PageFunctions #pagetitle Archived
PageFunctions #pagesubtitle Archived
PageFunctions #pageexists Archived
PageFunctions #varset Archived
PageFunctions #varget Archived
PageFunctions #varcapset Archived
PageFunctions #cshow Archived
PageFunctions #varaset Archived
PageFunctions #varaget Archived
ParserFunctions (extended) #expr (extended) Archived
ParserFunctions (extended) #ifexpr (extended) Archived
ParserFunctions (extended) #min Archived
ParserFunctions (extended) #max Archived
ParserFunctions (extended) #if Archived
ParserFunctions (extended) #ifeq Archived
ParserFunctions (extended) #ifexist Archived
ParserFunctions (extended) #rel2abs Archived
ParserFunctions (extended) #switch Archived
ParserFunctions (extended) #time Archived
Pipe Escape #! 1.23+
QPoll #qpuserchoice Archived
RegexTools #regex Archived
RegexTools #regex_vars Archived
SecureProperties #pg Archived
SecureProperties #ps Archived
SecureProperties #pf Archived
SecureProperties #gg Archived
SecureProperties #gs Archived
Semantic MediaWiki #ask 1.27+
Semantic MediaWiki #concept 1.27+
Semantic MediaWiki #info 1.27+
Semantic MediaWiki #show 1.27+
Semantic MediaWiki #set 1.27+
StringFunctions #len 1.7+
StringFunctions #pos 1.7+
StringFunctions #rpos 1.7+
StringFunctions #sub 1.7+
StringFunctions #pad 1.7+
StringFunctions #replace 1.7+
StringFunctions #explode 1.7+
StringFunctions #urlencode 1.7+
StringFunctions #urldecode 1.7+
TreeAndMenu #tree 1.23+
TreeAndMenu #menu 1.23+
Variables #vardefine 1.29+
Variables #vardefineecho 1.29+
Variables #var 1.29+
Variables #varexists 1.29+
Variables #var_final 1.29+
Wikibase Client #property
Wikibase Client #statements


Смотрите также