Jump to content

Module:Episode: Difference between revisions

From Semantic Stargate Wiki
Content deleted Content added
No edit summary
No edit summary
Line 1: Line 1:
local data = mw.loadData("Module:Episode/data")
local data = require("Module:Episode/data")
local p={}
local p = {}


function p.getInfo(frame)
function p.getEpisode(frame)
local episode = frame.args[1]
local key = string.lower(frame.args[1] or "")
local entry = data[key]
local nmspace, episodelink, episodetitle = unpack(data[episode])

if nmspace == "" then
if not entry then
return string.format("Episode link = %s, Episode title = %s", episodelink, episodetitle)
return "Episode not found"
else
end
return string.format("Namespace = " .. nmspace .. ", Episode link = ") -- .. episodelink .. ", Episode title = " .. episodetitle)

end
local ns, link, title = unpack(entry)

-- If namespace is empty or nil, omit it
if ns == "" or ns == nil then
return string.format("[[%s|%s]]", link, title)
else
return string.format("[[%s:%s|%s]]", ns, link, title)
end
end
end



Revision as of 17:04, 21 July 2025

Documentation icon Module documentation[create]
local data = require("Module:Episode/data")
local p = {}

function p.getEpisode(frame)
    local key = string.lower(frame.args[1] or "")
    local entry = data[key]

    if not entry then
        return "Episode not found"
    end

    local ns, link, title = unpack(entry)

    -- If namespace is empty or nil, omit it
    if ns == "" or ns == nil then
        return string.format("[[%s|%s]]", link, title)
    else
        return string.format("[[%s:%s|%s]]", ns, link, title)
    end
end

return p