Modul:TemplUtl: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
2019-02-19
K (Änderungen von Felix Koenig~dewiki (Diskussion) auf die letzte Version von PerfektesChaos zurückgesetzt) |
(2019-02-19) |
||
Zeile 1: | Zeile 1: | ||
local TemplUtl = { suite = "TemplUtl", | local TemplUtl = { suite = "TemplUtl", | ||
serial = "2019-02- | serial = "2019-02-19" }; | ||
Zeile 201: | Zeile 201: | ||
TemplUtl.fakes = function ( array, frame, ahead ) | TemplUtl.fakes = function ( array, frame, ahead, answer ) | ||
-- Simulation of template transclusions | -- Simulation of template transclusions | ||
-- Precondition: | -- Precondition: | ||
-- array | -- array -- table, with template title strings | ||
-- frame | -- frame -- object, or nil | ||
-- ahead | -- ahead -- string, or nil, with common prefix | ||
-- answer -- true, or nil, for list creation | |||
-- Postcondition: | |||
-- Returns string, if answer requested | |||
local e = framing( frame ); | local e = framing( frame ); | ||
local f = function ( a ) | local f = function ( a ) | ||
Zeile 212: | Zeile 215: | ||
end | end | ||
local s = ahead or ""; | local s = ahead or ""; | ||
local r; | |||
for k, v in pairs( array ) do | for k, v in pairs( array ) do | ||
if type( k ) == "number" and | if type( k ) == "number" and | ||
type( v ) == "string" then | type( v ) == "string" then | ||
v = mw.text.trim( v ); | v = mw.text.trim( v ); | ||
pcall( f, s .. v ); | pcall( f, s .. v ); | ||
if answer then | |||
if r then | |||
r = r .. "\n"; | |||
else | |||
r = ""; | |||
end | |||
r = string.format( "%s* [[Template:%s|%s]]", r, v, v ); | |||
end | |||
end | end | ||
end -- for k, v | end -- for k, v | ||
return r; | |||
end -- TemplUtl.fakes() | end -- TemplUtl.fakes() | ||
Zeile 662: | Zeile 675: | ||
function p.fakes( frame ) | function p.fakes( frame ) | ||
TemplUtl.fakes( frame.args, frame, frame.args.prefix ); | local list = ( frame.args.list == "1" ); | ||
return ""; | local r = TemplUtl.fakes( frame.args, | ||
frame, | |||
frame.args.prefix, | |||
list ); | |||
return r or ""; | |||
end -- p.fakes | end -- p.fakes | ||