Module:CGTBox

De USAC-CGT
Aller à la navigation Aller à la recherche

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

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

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

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

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

	
    return returnBox(title, contents)
end

return p