Vikipedio:Lua/Komparo de Lua-funkcioj kaj vikitekstoj
| |||
Kategorioj | |||
---|---|---|---|
Ŝablonoj | |||
| |||
Vidu ankaŭ | |||
Komentoj | |||
|
|||
Tio estas listo de Lua-funkcioj kaj la vikitekstaj malkomponilaj funkcioj kaj magiaj vortoj, al kiu ili estas kompareblaj.
Malkomponilaj funkcioj
redaktiVikiteksto | Lua |
---|---|
{{#if: x | ne malplena | malplena}} | if x then
'ne malplena'
else
'malplena'
end
|
{{#ifeq: x | y | sama | malsama}} | if x == y then
'sama'
else
'malsama'
end
|
{{#iferror: function | malbona | bona }} |
if tostring(mw.getCurrentFrame():preprocess('function')):find('<strong class="error"') then
'malbona'
else
'bona'
end
|
{{#ifexpr: 1+2=3 |vera|malvera}} | if 1 + 2 == 3 then
'vera'
else
'malvera'
end
|
[Multekosta] {{#ifexist: namespace:title | ekzistas | ne ekzistas }} |
[Multekosta]
if mw.title.new( 'title', 'namespace' ).exists == true then
"ekzistas"
else
"ne ekzistas"
end
|
rel2abs | |
{{#switch: {{{1}}} | foo = Foo | Bar }} | local cases = {
default = "Bar",
foo = "Foo",
}
local pframe = frame:getParent()
local arg = pframe.args[1]
cases[arg] or cases["default"]
|
{{#time: format | timestamp }} | mw.getContentLanguage():formatDate( 'format', 'timestamp' )
|
{{#timel: format | timestamp }} | mw.getContentLanguage():formatDate( 'format', 'timestamp', 1 )
|
titleparts |
Matematikaj
redaktiMalsame al Vikikodo, lua ne uzas funkciojn kiel ifexpr
kaj expr
. Aldonu la lua operatorojn kaj funkciojn rekte al via modulo.
Grupigo
Vikikodo | Lua |
---|---|
() | () |
Numeroj
Vikikodo | Lua |
---|---|
1234.5 | 1234.5 |
2e3 | 2e3 |
pi | math.pi |
e | |
2+2 | 2+2 |
2-1 | 2-1 |
Unulokaj
Vikikodo | Lua |
---|---|
not | not |
ceil1.2 | math.ceil(1.2) |
trunc | |
floor1.2 | math.floor(1.2) |
abs-2 | math.abs(-2) |
exp43 | math.exp(43) |
ln2 | math.log(2) |
cos0.1 | math.cos(0.1) |
tan0.1 | math.tan(0.1) |
acos0.1 | math.acos(0.1) |
asin0.1 | math.asin(0.1) |
atan0.1 | math.atan(0.1) |
Duumaj
Vikikodo | Lua |
---|---|
2^3 | 2^3 |
2*3 | 2*3 |
2/3 2div3 |
2/3 |
30mod7 | 30%7 |
+2 | 2 |
-2 | -2 |
Logikaj
Vikikodo | datumspeco | Lua | datumspeco |
---|---|---|---|
3.0=3 | entjero (0 aŭ 1) | 3.0==3 | bulea (vera aŭ malvera) |
3!=4 3<>4 |
entjero | 3~=4 | bulea |
4>3 | entjero | 4>3 | bulea |
4>=3 | entjero | 4>=3 | bulea |
3<=4 | entjero | 3<=4 | bulea |
3<=4 | entjero | 3<=4 | bulea |
and | entjero | and | bulea |
or | entjero | or | bulea |
Magiaj vortoj
redaktiDato kaj tempo
redaktiVikikodo | Lua |
---|---|
{{CURRENTYEAR}} | mw.getContentLanguage():formatDate("Y")
os.date( "%Y" )
|
{{CURRENTMONTH}} | mw.getContentLanguage():formatDate("m")
os.date( "%m" )
|
{{CURRENTMONTHNAME}} | mw.getContentLanguage():formatDate( 'F' )
|
{{CURRENTMONTHNAMEGEN}} | mw.getContentLanguage():formatDate( 'xg' )
|
{{CURRENTMONTHABBREV}} | mw.getContentLanguage():formatDate( 'M' )
|
{{CURRENTDAY}} | os.date( "%e" )
|
{{CURRENTDAY2}} | os.date( "%d" )
|
{{CURRENTDOW}} | os.date( "%w" )
|
{{CURRENTDAYNAME}} | mw.getContentLanguage():formatDate( 'l' )
|
{{CURRENTTIME}} | os.date( "%R" )
|
{{CURRENTHOUR}} | os.date( "%H" )
|
{{CURRENTWEEK}} | mw.getContentLanguage():formatDate( 'W' )
|
{{CURRENTTIMESTAMP}} |
Teknikaj metadatumoj
redaktiVikikodo | Lua |
---|---|
{{SITENAME}} | mw.site.siteName
|
{{SERVER}} | mw.site.server
|
{{SERVERNAME}} | |
{{DIRMARK}} | mw.language.getContentLanguage():getDirMark()
|
{{SCRIPTPATH}} | mw.site.scriptPath
|
{{STYLEPATH}} | mw.site.stylePath
|
{{CURRENTVERSION}} | mw.site.currentVersion
|
{{CONTENTLANGUAGE}} | mw.getContentLanguage():getCode()
|
{{PAGEID}} | mw.title.getCurrentTitle().id
|
{{PAGESIZE:page name}} | |
{{PROTECTIONLEVEL:edit}} | [Multekosta]local protection = mw.title.getCurrentTitle().protectionLevels["edit"]
table.concat(protection)
|
{{REVISIONID}} | |
{{REVISIONDAY}} | |
{{REVISIONDAY}} | |
{{REVISIONMONTH}} | |
{{REVISIONMONTH1}} | |
{{REVISIONYEAR}} | |
{{REVISIONTIMESTAMP}} | |
{{REVISIONUSER}} | |
{{DISPLAYTITLE:title}} | |
{{DEFAULTSORT:sortkey}} |
Statistiko
redaktiVikikodo | Lua |
---|---|
{{NUMBEROFPAGES}} | mw.site.stats.pages
|
{{NUMBEROFARTICLES}} | mw.site.stats.articles
|
{{NUMBEROFFILES}} | mw.site.stats.files
|
{{NUMBEROFEDITS}} | mw.site.stats.edits
|
{{NUMBEROFVIEWS}} | mw.site.stats.views
|
{{NUMBEROFUSERS}} | mw.site.stats.users
|
{{NUMBEROFADMINS}} | mw.site.stats.admins
|
{{NUMBEROFACTIVEUSERS}} | mw.site.stats.activeUsers
|
[Multekosta] {{PAGESINCATEGORY:categoryname}} |
[Multekosta]
mw.site.stats.pagesInCategory( 'categoryname' )
|
{{NUMBERINGROUP:groupname}} | mw.site.stats.usersInGroup( 'groupname' )
|
Paĝonomoj
redaktiVikikodo | Lua |
---|---|
{{FULLPAGENAME}} | mw.title.getCurrentTitle().prefixedText
|
{{PAGENAME}} | mw.title.getCurrentTitle().text
|
{{BASEPAGENAME}} | mw.title.getCurrentTitle().baseText
|
{{SUBPAGENAME}} | mw.title.getCurrentTitle().subpageText
|
{{SUBJECTPAGENAME}} | [Multekosta]mw.title.getCurrentTitle().subjectPageTitle
aŭ nemultekosta alternativo: mw.title.getCurrentTitle().subjectNsText .. ":" .. mw.title.getCurrentTitle().text
|
{{TALKPAGENAME}} | [Multekosta]mw.title.getCurrentTitle().talkPageTitle
|
Nomspacoj
redaktiVikikodo | Lua |
---|---|
{{NAMESPACE}} | mw.title.getCurrentTitle().nsText
|
{{NAMESPACENUMBER}} | mw.title.getCurrentTitle().namespace
|
{{SUBJECTSPACE}} | mw.title.getCurrentTitle().subjectNsText
|
{{TALKSPACE}} |
URL datumoj
redaktiVikikodo | 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' )
|
Nomspacoj
redaktiVikikodo | Lua |
---|---|
{{ns:0}} | mw.site.namespaces[0].name
|
{{ns:Project}} | mw.site.namespaces.Project.name
|
Tekstaranĝo
redaktiVikikodo | 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}} |
Asimilado
redaktiVikikodo | 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()
|
Mikso
redaktiVikikodo | 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'
} )
|