« 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 3 : Ligne 3 :
local title = mw.title.getCurrentTitle().text
local title = mw.title.getCurrentTitle().text
local contents = {} -- table for html element for the contents of the box
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


--
--
Ligne 44 : Ligne 35 :
return box
return box
end    
end    
function p.hello( frame )
contents[#contents + 1] = mw.html.create('span')
  :wikitext("Hello, world 2!")
  :done()
    return returnBox(title, contents)
end


return p
return p

Version du 22 septembre 2023 à 18:25

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('div')
		:wikitext(title)
		: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(p.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