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

De Buck Wiki
Aller à la navigation Aller à la recherche
Contenu supprimé Contenu ajouté
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
-- Used to extract the exact title of an episode
-- Used to extract the exact title of an episode


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


local TITLE_TEMPLATE = [[
local TITLE_TEMPLATE = [[
Ligne 32 : Ligne 32 :
TITLE_TEMPLATE,
TITLE_TEMPLATE,
article,
article,
articleData.Article--,
articleData.Article,
-- articleData.Title
articleData.Title
)
)
end
end

Version du 25 août 2022 à 17:19

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

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

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

-- Trim whitespace from args, and treat blank args as nil
local function preprocessArg(s)
    if not s then
        return nil
    end
    s = string.lower (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 = frame.args
	local article = preprocessArg(args[1])

	local articleData = data[article]
	
	return string.format(
		TITLE_TEMPLATE,
		article,
		articleData.Article,
		articleData.Title
		)
end

return p