Modul:TemplateData: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
2017-04-12
wp>PerfektesChaos (2017-04-11) |
wp>PerfektesChaos (2017-04-12) |
||
Zeile 1: | Zeile 1: | ||
local TemplateData = { serial = "2017-04- | local TemplateData = { serial = "2017-04-12", | ||
suite = "TemplateData" } | suite = "TemplateData" } | ||
--[=[ | --[=[ | ||
Zeile 132: | Zeile 132: | ||
-- Returns number, or nil | -- Returns number, or nil | ||
local seek = string.format( Permit.search, | local seek = string.format( Permit.search, | ||
ask:gsub( "([%-()^$%%])", "%%%1" ) ) | ask:gsub( "([%-()^$%[%]%%])", "%%%1" ) ) | ||
local i, k = Data.source:find( seek, at ) | local i, k = Data.source:find( seek, at ) | ||
local r, slice, source | local r, slice, source | ||
Zeile 249: | Zeile 249: | ||
-- 2 -- table of other versions, if any | -- 2 -- table of other versions, if any | ||
local n = 0 | local n = 0 | ||
local variants = { } | |||
local r1, r2 | local r1, r2 | ||
if not Data.slang then | if not Data.slang then | ||
Zeile 256: | Zeile 257: | ||
if type( v ) == "string" then | if type( v ) == "string" then | ||
v = mw.text.trim( v ) | v = mw.text.trim( v ) | ||
if v | if v ~= "" then | ||
variants[ k ] = v | |||
n = n + 1 | |||
n = n + 1 | |||
end | end | ||
end | end | ||
end -- for k, v | end -- for k, v | ||
if n > 0 then | if n > 0 then | ||
for k, v in pairs( | for k, v in pairs( variants ) do | ||
if v then | if v then | ||
if n == 1 then | if n == 1 then | ||
r1 = v | r1 = v | ||
elseif k:lower() == Data.slang then | elseif k:lower() == Data.slang then | ||
variants[ k ] = nil | |||
r1 = v | r1 = v | ||
r2 = | r2 = variants | ||
break -- for k, v | break -- for k, v | ||
end | end | ||
Zeile 280: | Zeile 278: | ||
if not r1 then | if not r1 then | ||
local seek = string.format( "^%s-", Data.slang ) | local seek = string.format( "^%s-", Data.slang ) | ||
for k, v in pairs( | for k, v in pairs( variants ) do | ||
if v and k:lower():match( seek ) then | if v and k:lower():match( seek ) then | ||
variants[ k ] = nil | |||
r1 = v | r1 = v | ||
r2 = | r2 = variants | ||
break -- for k, v | break -- for k, v | ||
end | end | ||
Zeile 293: | Zeile 291: | ||
for i = 1, #others do | for i = 1, #others do | ||
seek = others[ i ] | seek = others[ i ] | ||
if | if variants[ seek ] then | ||
r1 = | r1 = variants[ seek ] | ||
variants[ seek ] = nil | |||
r2 = | r2 = variants | ||
break -- for i | break -- for i | ||
end | end | ||
Zeile 302: | Zeile 300: | ||
end | end | ||
if not r1 then | if not r1 then | ||
for k, v in pairs( | for k, v in pairs( variants ) do | ||
if v then | if v then | ||
variants[ k ] = nil | |||
r1 = v | r1 = v | ||
r2 = | r2 = variants | ||
break -- for k, v | break -- for k, v | ||
end | end | ||
Zeile 834: | Zeile 832: | ||
local translated | local translated | ||
v, translated = faraway( v ) | v, translated = faraway( v ) | ||
if translated and | if v then | ||
if translated and | |||
k == "description" then | |||
elem = { [ 1 ] = fair( v ), | |||
[ 2 ] = translated } | |||
else | |||
elem = fair( v ) | |||
end | |||
else | else | ||
elem = | elem = false | ||
end | end | ||
end | end | ||
if scope:find( "nowiki", 1, true ) then | if v then | ||
if scope:find( "nowiki", 1, true ) then | |||
elem = mw.text.nowiki( v ) | |||
else | |||
v = flat( v ) | |||
end | |||
end | end | ||
else | else | ||
Zeile 850: | Zeile 855: | ||
v = nil | v = nil | ||
elem = nil | elem = nil | ||
elseif k == "format" and not access then | |||
v = mw.text.decode( v ) | |||
elem = v | |||
elseif k == "inherits" then | elseif k == "inherits" then | ||
elem = v | elem = v |