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

De USAC-CGT
Aller à la navigation Aller à la recherche
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 8 : Ligne 8 :
  :wikitext("Hello, world 2!")
  :wikitext("Hello, world 2!")
  :done()
  :done()
local ret = returnBox()
    return returnBox(title, contents)
    return ret
end
end


Ligne 28 : Ligne 27 :
-- Génère la boite à partir du titre (title) et de la table contents
-- Génère la boite à partir du titre (title) et de la table contents
--
--
local function returnBox()
local function returnBox(title, contents)
--box
--box
local box = mw.html.create('div')
local box = mw.html.create('div')

Version du 22 septembre 2023 à 18:23

La documentation pour ce module peut être créée à Module:CGTBox/doc

local p = {} --p stands for package

local title = mw.title.getCurrentTitle().text
local contents = {} -- table for html element for the contents of the box

function p.hello( frame )
	contents[#contents + 1] = mw.html.create('span')
	  :wikitext("Hello, world 2!")
	  :done()

	
    return returnBox(title, contents)
end

--
-- Retourne le titre sous forme html
--
local function addTitle( title )
	return mw.html.create('div')
		:addClass('entete')
		:node('div')
		:wikitext(title)
		:allDone()
end

--
-- Génère la boite à partir du titre (title) et de la table contents
--
local function returnBox(title, contents)
	--box
	local box = mw.html.create('div')
	  :addClass('infobox_v3')
	
	--Title
	box:node(p.addTitle(title))

	--contents
	for i, v in ipairs(contents) do
		box:node(v)
	end
	
	box:done()
	
	return box
end	  

return p