« 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 12 : Ligne 12 :
end
end


function returnBox()
--
-- 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()
--box
--box
local box = mw.html.create('div')
local box = mw.html.create('div')
Ligne 18 : Ligne 32 :
--Title
--Title
box:node(
box:node(p.addTitle(title))
mw.html.create('div')
:addClass('entete')
:wikitext(title)
:done())


--contents
--contents

Version du 22 septembre 2023 à 18:17

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()
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()
	--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