Modul:TemplUtl: Unterschied zwischen den Versionen

986 Bytes hinzugefügt ,  17. Februar 2019
2019-02-16
(2019-02-01)
(2019-02-16)
Zeile 1: Zeile 1:
local TemplUtl = { suite  = "TemplUtl",
local TemplUtl = { suite  = "TemplUtl",
                   serial = "2019-02-01" };
                   serial = "2019-02-16" };




Zeile 173: Zeile 173:
     --    access  -- string, or nil; page name (template)
     --    access  -- string, or nil; page name (template)
     --    frame  -- object, or nil
     --    frame  -- object, or nil
    local f = function ( a )
                  framing( frame ):expandTemplate{ title = a };
              end
     local s;
     local s;
     if type( access ) == "string" then
     if type( access ) == "string" then
Zeile 184: Zeile 181:
     end
     end
     if not s then
     if not s then
         s = mw.title.getCurrentTitle().text;
        local cnf, lucky;
         s = string.format( "Module:%s/self", TemplUtl.suite );
        lucky, cnf = pcall( mw.loadData, s );
        if type( cnf ) == "table"  and
          cnf.loop == true then
            s = mw.title.getCurrentTitle().text;
        else
            s = false;
        end
    end
    if s then
        local f = function ()
                      framing( frame ):expandTemplate{ title = s };
                  end
        pcall( f );
     end
     end
    pcall( f, s );
end -- TemplUtl.fake()
end -- TemplUtl.fake()
TemplUtl.fakes = function ( array, frame, ahead )
    -- Simulation of template transclusions
    -- Precondition:
    --    array  -- table, with template title strings
    --    frame  -- object, or nil
    --    ahead  -- string, or nil, with common prefix
    local e = framing( frame );
    local f = function ( a )
                  e:expandTemplate{ title = a };
              end
    local s = ahead or "";
    for k, v in pairs( array ) do
        if type( k ) == "number" then
            pcall( f, s .. v );
        end
    end -- for k, v
end -- TemplUtl.fakes()




Zeile 628: Zeile 658:
     return "";
     return "";
end -- p.fake
end -- p.fake
function p.fakes( frame )
    TemplUtl.fakes( frame.args, frame, frame.args.prefix );
    return "";
end -- p.fakes


function p.isRedirect()
function p.isRedirect()
Anonymer Benutzer