From Wikipedia, the free encyclopedia
This is a list of Lua functions and the wikitext parser functions and magic words that they are comparable to.
It is slightly out of date for what wikitext parser functions can do.
Magic words
Date and time
Wikicode |
Lua
|
{{CURRENTYEAR}} |
mw.getContentLanguage():formatDate( 'Y' )
or
|
{{CURRENTMONTH}} |
mw.getContentLanguage():formatDate( 'm' )
or
|
{{CURRENTMONTH1}} |
mw.getContentLanguage():formatDate( 'n' )
|
{{CURRENTMONTHNAME}} |
mw.getContentLanguage():formatDate( 'F' )
|
{{CURRENTMONTHNAMEGEN}} |
mw.getContentLanguage():formatDate( 'xg' )
|
{{CURRENTMONTHABBREV}} |
mw.getContentLanguage():formatDate( 'M' )
|
{{CURRENTDAY}} |
mw.getContentLanguage():formatDate( 'j' )
|
{{CURRENTDAY2}} |
mw.getContentLanguage():formatDate( 'd' )
or
|
{{CURRENTDOW}} |
mw.getContentLanguage():formatDate( 'w' )
or
|
{{CURRENTDAYNAME}} |
mw.getContentLanguage():formatDate( 'l' )
|
{{CURRENTTIME}} |
mw.getContentLanguage():formatDate( 'H:i' )
or
|
{{CURRENTHOUR}} |
mw.getContentLanguage():formatDate( 'H' )
or
|
{{CURRENTWEEK}} |
mw.getContentLanguage():formatDate( 'W' )
|
{{CURRENTTIMESTAMP}} |
mw.getContentLanguage():formatDate( 'YmdHis' )
|
Wikicode |
Lua
|
{{SITENAME}} |
|
{{SERVER}} |
|
{{SERVERNAME}} |
|
{{DIRMARK}} |
mw.language.getContentLanguage():getDirMark()
|
{{SCRIPTPATH}} |
|
{{STYLEPATH}} |
|
{{CURRENTVERSION}} |
|
{{CONTENTLANGUAGE}} |
mw.getContentLanguage():getCode()
|
{{PAGEID}} |
mw.title.getCurrentTitle().id
|
{{PAGESIZE:page name}} |
|
{{PROTECTIONLEVEL:edit}} |
[Expensive]local protection = mw.title.getCurrentTitle().protectionLevels["edit"]
table.concat(protection)
|
{{REVISIONID}} |
|
{{REVISIONDAY}} |
|
{{REVISIONDAY}} |
|
{{REVISIONMONTH}} |
|
{{REVISIONMONTH1}} |
|
{{REVISIONYEAR}} |
|
{{REVISIONTIMESTAMP}} |
|
{{REVISIONUSER}} |
|
{{DISPLAYTITLE:title}} |
|
{{DEFAULTSORT:sortkey}} |
|
Statistics
Wikicode |
Lua
|
{{NUMBEROFPAGES}} |
|
{{NUMBEROFARTICLES}} |
|
{{NUMBEROFFILES}} |
|
{{NUMBEROFEDITS}} |
|
{{NUMBEROFVIEWS}} |
|
{{NUMBEROFUSERS}} |
|
{{NUMBEROFADMINS}} |
|
{{NUMBEROFACTIVEUSERS}} |
mw.site.stats.activeUsers
|
[Expensive] {{PAGESINCATEGORY:categoryname}} |
[Expensive]
mw.site.stats.pagesInCategory( 'categoryname' )
|
{{NUMBERINGROUP:groupname}} |
mw.site.stats.usersInGroup( 'groupname' )
|
Page names
Wikicode |
Lua
|
{{FULLPAGENAME}} |
mw.title.getCurrentTitle().prefixedText
|
{{PAGENAME}} |
mw.title.getCurrentTitle().text
|
{{BASEPAGENAME}} |
mw.title.getCurrentTitle().baseText
|
{{SUBPAGENAME}} |
mw.title.getCurrentTitle().subpageText
|
{{SUBJECTPAGENAME}} |
[Expensive]mw.title.getCurrentTitle().subjectPageTitle
or an non expensive alternative:
mw.title.getCurrentTitle().subjectNsText .. ":" .. mw.title.getCurrentTitle().text
|
{{TALKPAGENAME}} |
[Expensive]mw.title.getCurrentTitle().talkPageTitle
|
Namespaces
Wikicode |
Lua
|
{{NAMESPACE}} |
mw.title.getCurrentTitle().nsText
|
{{NAMESPACENUMBER}} |
mw.title.getCurrentTitle().namespace
|
{{SUBJECTSPACE}} |
mw.title.getCurrentTitle().subjectNsText
|
{{TALKSPACE}} |
|
URL data
Wikicode |
Lua
|
{{localurl:page|query}} |
mw.uri.localUrl( 'page', 'query' )
|
{{fullurl:page|query}} |
mw.uri.fullUrl( 'page', 'query' )
|
{{canonicalurl:page|query}} |
mw.uri.canonicalUrl( 'page', 'query' )
|
{{filepath:file name}} |
|
{{urlencode:string|QUERY}} |
mw.uri.encode( 'string', QUERY )
|
{{anchorencode:string}} |
mw.uri.anchorEncode( 'string' )
|
Namespaces
Wikicode |
Lua
|
{{ns:0}} |
mw.site.namespaces[0].name
|
{{ns:Project}} |
mw.site.namespaces.Project.name
|
Wikicode |
Lua
|
{{formatnum:number}} |
mw.getContentLanguage():formatNum( number )
|
#dateformat |
|
{{lc:string}} |
mw.ustring.lower( 'string' )
|
{{lcfirst:string}} |
mw.getContentLanguage():lcfirst( 'string' )
|
{{uc:string}} |
mw.ustring.upper( 'string' )
|
{{ucfirst:string}} |
mw.getContentLanguage():ucfirst( 'string' )
|
{{padleft:xyz|stringlength}} |
|
{{padright:xyz|stringlength}} |
|
Localisation
Wikicode |
Lua
|
{{plural:2|is|are}} |
mw.getContentLanguage():plural( 2, 'is', 'are' )
|
{{grammar:N|noun}} |
mw.getContentLanguage():grammar( 'N', 'noun' )
|
{{gender:username|male|female|neutral }} |
mw.getContentLanguage():gender( 'username', { 'male', 'female', 'neutral' } )
|
{{int:message}} |
mw.message.new( 'message' ):plain()
|
{{int:editsectionhint|MediaWiki}} |
mw.message.new( 'editsectionhint', 'MediaWiki' ):plain()
|
Miscellaneous
Wikicode |
Lua
|
{{#language:code|inlanguage}} |
mw.language.fetchLanguageName( 'code', 'inLanguage' )
|
{{#special:special page name}} |
|
{{#speciale:special page name}} |
|
{{#tag:tagname
|some text
|attribute1=value1
|attribute2=value2
}} |
frame:extensionTag( 'tagname', 'some text', {
attribute1 = 'value1', attribute2 = 'value2'
} )
|