« Module:Liste déroulante » : différence entre les versions

De Les Archives de Vault-Tec
Kharmitch (discussion | contributions)
mAucun résumé des modifications
Kharmitch (discussion | contributions)
Aucun résumé des modifications
 
Ligne 7 : Ligne 7 :
local title = outils.trim(params[1]) or 'Titre ?'
local title = outils.trim(params[1]) or 'Titre ?'
local res = mw.html.create('div')
local hiddenList = mw.html.create('ul')
res
:addClass('dropdown')
:tag('span'):wikitext(title):done()
:tag('ul')
for index, item in pairs(params) do
for index, item in pairs(params) do
if(index ~= 1) then
if(index ~= 1) then
res
hiddenList
:tag('li'):wikitext(item):done()
:tag('li'):wikitext(item):done()
end
end
end
end
hiddenList:done()
local res = mw.html.create('div')
res
:addClass('dropdown')
:tag('span'):wikitext(title):done()
:node(hiddenList)
res:allDone()
res:allDone()

Dernière version du 5 décembre 2019 à 23:00

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

local p = {}
local outils = require('Module:Outils')

-- Génère une liste déroulante
function p.make(frame)
	local params = outils.extractArgs(frame)
	local title = outils.trim(params[1]) or 'Titre ?'
	
	local hiddenList = mw.html.create('ul')
	
	for index, item in pairs(params) do
		if(index ~= 1) then
			hiddenList
				:tag('li'):wikitext(item):done()
		end
	end
	
	hiddenList:done()
	
	local res = mw.html.create('div')
	res
		:addClass('dropdown')
		:tag('span'):wikitext(title):done()
		:node(hiddenList)
	
	res:allDone()
	return res
end

return p