Parser function extensions/zh

Category:Outdated pages/zh

“解析器函数”是一种模板式的构造,它根据至少一个未命名参数返回一个值,该参数与函数名之间用冒号 [:] 分隔。也可能有更多的参数;像普通模板一样,这些额外的参数每个前面都由一个“管道”符号 [|] 引导。如果函数名以井号字符 [#] 开头(这可以防止与命名空间和跨维基前缀发生冲突),这个字符可能或可能不被视为名称的一部分。如果它被视为名称的一部分,那么语法形式如下:

{{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., ). Allowing such codes is harmless if an alternative code is also allowed, e.g. "\" for "|".

函數列表

函數MediaWiki版本
built-inlc1.7+
built-inuc1.7+
built-inlcfirst1.7+
built-inucfirst1.7+
built-inurlencode1.7+
built-inanchorencode1.8+
built-inlocalurl1.7+
built-infullurl1.7+
built-in#language1.7+
built-in#special1.9+
built-in#tag1.12+
解析器函數 (usage)#expr1.19+
解析器函數 (usage)#ifexpr1.19+
解析器函數 (usage)#if1.19+
解析器函數 (usage)#ifeq1.19+
解析器函數 (usage)#ifexist1.19+
解析器函數 (usage)#rel2abs1.19+
解析器函數 (usage)#titleparts1.19+
解析器函數 (usage)#switch1.19+
解析器函數 (usage)#time1.19+
AddScriptCss#addscriptArchived
#arraydefine1.23+
#arraydiff1.23+
#arrayindex1.23+
#arrayintersect1.23+
#arraymerge1.23+
#arrayprint1.23+
#arrayreset1.23+
#arraysearch1.23+
#arraysearcharray1.23+
#arraysize1.23+
#arrayslice1.23+
#arraysort1.23+
#arraytohash1.23+
#arrayunion1.23+
#arrayunique1.23+
#hashtoarray1.23+
Attachments#attach1.31+
Attachments#exturl1.31+
巴別#babel1.30+
CSS#css1.25+
Coordinate#coordinateArchived
Counter#+1.15+
Data#dataArchived
Data#sortArchived
DynamicFunctions#argArchived
DynamicFunctions#ipArchived
DynamicFunctions#randArchived
DynamicFunctions#skinArchived
DynamicPageList (第三方)#dplArchived
DynamicPageList3#dpl1.39+
ExpandAfter#expandafter (deprecated, see: #tag)Archived
ForeachFunction#foreachxArchived
ForeachFunction#foreachyArchived
HasCategory#ifhascatArchived
HideNamespace#hidensArchived
HideNamespace#unhidensArchived
ImageLink#img (old: #imagelink, deprecated)Archived
Infobox Data Capture#dataentryArchived
Infobox Data Capture#listsplitArchived
InterWikiLinkManager#iwlArchived
KeyValue#keyvalueArchived
標記式章節嵌入#lst1.25+
標記式章節嵌入#lstx1.25+
標記式章節嵌入#lsth1.25+
LoopFunctions#for1.23+
LoopFunctions#foreach1.25+
迴圈#while1.25+
迴圈#dowhile1.25+
迴圈#forargs1.25+
迴圈#fornumargs1.25+
迴圈#loop1.25+
地圖#geocode1.27+
地圖#display_map1.27+
地圖#display_point1.27+
地圖#coordinates1.27+
地圖#distance1.27+
MediaFunctions#media..1.23+
PageAfterAndBefore#pagebeforeArchived
PageAfterAndBefore#pageafterArchived
PageAfterAndBefore#firstpageArchived
PageAfterAndBefore#lastpageArchived
PageFunctions#pagetitleArchived
PageFunctions#pagesubtitleArchived
PageFunctions#pageexistsArchived
PageFunctions#varsetArchived
PageFunctions#vargetArchived
PageFunctions#varcapsetArchived
PageFunctions#cshowArchived
PageFunctions#varasetArchived
PageFunctions#varagetArchived
ParserFunctions (extended)#expr (extended)Archived
ParserFunctions (extended)#ifexpr (extended)Archived
ParserFunctions (extended)#minArchived
ParserFunctions (extended)#maxArchived
ParserFunctions (extended)#ifArchived
ParserFunctions (extended)#ifeqArchived
ParserFunctions (extended)#ifexistArchived
ParserFunctions (extended)#rel2absArchived
ParserFunctions (extended)#switchArchived
ParserFunctions (extended)#timeArchived
Pipe Escape#!1.23+
QPoll#qpuserchoiceArchived
RegexTools#regexArchived
RegexTools#regex_varsArchived
SecureProperties#pgArchived
SecureProperties#psArchived
SecureProperties#pfArchived
SecureProperties#ggArchived
SecureProperties#gsArchived
Semantic MediaWiki#ask1.27+
Semantic MediaWiki#concept1.27+
Semantic MediaWiki#info1.27+
Semantic MediaWiki#show1.27+
Semantic MediaWiki#set1.27+
StringFunctions#len1.7+
StringFunctions#pos1.7+
StringFunctions#rpos1.7+
StringFunctions#sub1.7+
StringFunctions#pad1.7+
StringFunctions#replace1.7+
StringFunctions#explode1.7+
StringFunctions#urlencode1.7+
StringFunctions#urldecode1.7+
TreeAndMenu#tree1.23+
TreeAndMenu#menu1.23+
#vardefine1.29+
#vardefineecho1.29+
#var1.29+
#varexists1.29+
#var_final1.29+
#property
#statements


參見

Category:Customization techniques/zh#Parser%20function%20extensions/zh Category:Parser function extensions/zh#%20 Category:Extension examples/zh#%20
Category:Customization techniques/zh Category:Extension examples/zh Category:Outdated pages/zh Category:Parser function extensions/zh