Module:Icône de titre

De Lagny-sur-Marne Wiki
Révision datée du 25 décembre 2014 à 15:42 par Hlm Z. (discussion)
Aller à : navigation, rechercher

La documentation pour ce module peut être créée à Module:Icône de titre/doc

local p = {}

function p.main(frame)
	local args = {}
	local argsParent = frame:getParent().args
 
	--Paramètres vides interprétés par Lua
	for cle, val in pairs(argsParent) do
		if val ~= '' then
			args[cle] = mw.text.trim(val)
		end
	end
 
	return p._main(args)
end

function p._main(args)
	local res = mw.html.create():newline()
	local span = mw.html.create('span')
	local frame = mw.getCurrentFrame()
	local fichierWiki = '[[Fichier:%s|%spx|link=%s|%s|alt=%s]]'
 
 	span
 		:attr('title', args.texte or 'Exemple de texte')
 		:wikitext(mw.ustring.format(fichierWiki,
			args.image or 'Fairytale bookmark.png',
			args.taille or 20,
			args.lien or 'Modèle:Icône de titre',
			args['paramètre'] or 'Lorem',
			args.texte or 'Exemple de texte'))
 
	res
		:wikitext(frame:extensionTag('indicator', tostring(span), {
			name = args.id or 'IDTidauto_' .. math.random(500)
		}))
	
	if not args.id then
		res:wikitext('[[Catégorie:Page utilisant une icône de titre sans identifiant]]')
	end

	return tostring(res)
end

return p