« Module:Episode » : différence entre les versions

De Buck Wiki
Aller à la navigation Aller à la recherche
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 2 : Ligne 2 :


local p = {}
local p = {}
local getArgs = require("Module:Arguments").getArgs
local data = mw.loadData("Module:Episode/data")
local data = mw.loadData("Module:Episode/data")


local TITLE_TEMPLATE = [[
* Article: %s
* Title: %d
]]
-- Trim whitespace from args, and treat blank args as nil
local function preprocessArg(s)
    if not s then
        return nil
    end
    s = s:match('^%s*(.-)%s*$') -- trim whitespace
    if s == '' then
        return nil
    else
        return s
    end
end
-- Retrieving full episode title
-- Retrieving full episode title


function p.title(frame)
function p.title(frame)
args[1] = getArgs(frame)
local args = lc.frame.args
return p.title(args[1])
local article = preprocessArg(args[1])
local articleData = data[article]
return string.format(
TITLE_TEMPLATE,
article,
articleData.Article,
articleData.Title
)
end
end


return p
return p

Version du 25 août 2022 à 11:56

Documentation module[créer]
-- Used to extract the exact title of an episode

local p = {}
local data = mw.loadData("Module:Episode/data")

local TITLE_TEMPLATE = [[
* Article: %s
* Title: %d
]]

-- Trim whitespace from args, and treat blank args as nil
local function preprocessArg(s)
    if not s then
        return nil
    end
    s = s:match('^%s*(.-)%s*$') -- trim whitespace
    if s == '' then
        return nil
    else
        return s
    end
end
-- Retrieving full episode title

function p.title(frame)
	local args = lc.frame.args
	local article = preprocessArg(args[1])
	
	local articleData = data[article]
	
	return string.format(
		TITLE_TEMPLATE,
		article,
		articleData.Article,
		articleData.Title
		)
end

return p