Modul:TemplateData: Unterschied zwischen den Versionen
2017-04-09
wp>PerfektesChaos (2017-04-08) |
wp>PerfektesChaos (2017-04-09) |
||
Zeile 1: | Zeile 1: | ||
local TemplateData = { serial = "2017-04- | local TemplateData = { serial = "2017-04-09", | ||
suite = "TemplateData" } | suite = "TemplateData" } | ||
--[=[ | --[=[ | ||
Zeile 91: | Zeile 91: | ||
end | end | ||
end -- Fault() | end -- Fault() | ||
local function Fetch( ask ) | |||
-- Fetch module | |||
-- Parameter: | |||
-- ask -- string, with name | |||
-- "Multilingual" | |||
-- "Text" | |||
-- "WLink" | |||
-- Returns table of module | |||
-- error: Module not available | |||
local r | |||
if TemplateData.extern then | |||
r = TemplateData.extern[ ask ] | |||
else | |||
TemplateData.extern = { } | |||
end | |||
if not r then | |||
local lucky, g = pcall( require, "Module:" .. ask ) | |||
if type( g ) == "table" then | |||
r = g[ ask ]() | |||
TemplateData.extern[ ask ] = r | |||
else | |||
error( string.format( "Fetch(%s) %s", ask, g ) ) | |||
end | |||
end | |||
return r | |||
end -- Fetch() | |||
Zeile 327: | Zeile 356: | ||
end | end | ||
if r2 then | if r2 then | ||
local Multilingual = | local Multilingual = Fetch( "Multilingual" ) | ||
for k, v in pairs( r2 ) do | for k, v in pairs( r2 ) do | ||
if v and not Multilingual.isLang( k ) then | if v and not Multilingual.isLang( k ) then | ||
Zeile 361: | Zeile 390: | ||
p2[ k2 ] = v2 | p2[ k2 ] = v2 | ||
end -- for k2, v2 | end -- for k2, v2 | ||
for k2, v2 in pairs( p[ k ] ) do | if p[ k ] then | ||
for k2, v2 in pairs( p[ k ] ) do | |||
if type( v2 ) ~= "nil" then | |||
p2[ k2 ] = v2 | |||
end | |||
end -- for k2, v2 | |||
end | |||
p[ k ] = p2 | p[ k ] = p2 | ||
for k2, v2 in pairs( t[ v ] ) do | for k2, v2 in pairs( t[ v ] ) do | ||
Zeile 652: | Zeile 683: | ||
return r | return r | ||
end -- features() | end -- features() | ||
Zeile 732: | Zeile 734: | ||
end | end | ||
if r:find( "<", 1, true ) then | if r:find( "<", 1, true ) then | ||
local Text = | local Text = Fetch( "Text" ) | ||
r = Text.getPlain( r ) | r = Text.getPlain( r ) | ||
end | end | ||
if r:find( "[", 1, true ) then | if r:find( "[", 1, true ) then | ||
local WLink = | local WLink = Fetch( "WLink" ) | ||
if WLink.isBracketedURL( r ) then | if WLink.isBracketedURL( r ) then | ||
r = r:gsub( "%[([hf]tt?ps?://%S+) [^%]]+%]", "%1" ) | r = r:gsub( "%[([hf]tt?ps?://%S+) [^%]]+%]", "%1" ) |