« 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
 
(18 versions intermédiaires par le même utilisateur non affichées)
Ligne 2 : Ligne 2 :


local p = {}
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 = string.lower (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)
local args = frame.args
local articleData = mw.loadData( 'Module:Episode/data')
local article = preprocessArg(args[1])
local articlePage = frame.args[1]
local articleResource = articleData[articlePage]
local tab = mw.text.split (articleResource, " ")
local articleData = data[article]
return (tab[1])
return string.format(
TITLE_TEMPLATE,
article,
articleData.Article,
articleData.Title
)
end
end


return p
return p

Dernière version du 25 août 2022 à 14:25

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

local p = {}


-- Retrieving full episode title

function p.title(frame)
	local articleData = mw.loadData( 'Module:Episode/data')
	local articlePage = frame.args[1]
	local articleResource = articleData[articlePage]
	local tab = mw.text.split (articleResource, " ")
	
	return (tab[1])
	
end

return p