dev
Documentation icon Module documentation
[create]

The documentation for this module is missing. Click here to create it.

--- If I use switch ---
local p = {}
local fooBarData = mw.loadData( 'Module:Sandbox/Derekblue1/data' )

function p.fooBar( frame )
    local fooBarText = frame.args[1]

    return fooBarData[fooBarText] or fooBarText or ""
end

--- If I use if ---
local p = {}

function p.main( frame )
    local tArgs = frame:getParent()

    if not(tArgs.args[1]) then
        tArgs = frame
    end

    local sText = tArgs.args[1]
    local sTrueAction = tArgs.args[2] or tArgs.args["true"]
    local sFalseAction = tArgs.args[3] or tArgs.args["false"]

    if sText == nil or sText == "" then
        sText = mw.getCurrentFrame():preprocess(sFalseAction)
    else
        sText = mw.getCurrentFrame():preprocess(sTrueAction)
    end
    return sText
end
---- ifexist
local p = {}

function p.exists( frame )
    local tArgs = frame:getParent()
    if not(tArgs.args[1]) then
        tArgs = frame
    end

    local sText = tArgs.args[1]
    local sTrueAction = tArgs.args[2] or tArgs.args["true"]
    local sFalseAction = tArgs.args[3] or tArgs.args["false"]

    if sText and sText ~= "" then
        if  mw.title.new( sText ).exists then
            return sTrueAction
        else 
            return sFalseAction
        end
    end
end

--- if Loop
local p = {}

function p.appendloop( frame )
    local tArgs = frame:getParent()

    if not(tArgs.args[1]) then
       tArgs = frame
    end

    local sOutputText = ""

    for iKey,sValue in pairs(tArgs.args) do 
       sOutputText = sOutputText  .. sValue  .. ", "
    end

    return sOutputText 
end
return p
--- Note, it always ends with return p at the end of the script