« Module:Icône de titre » : différence entre les versions

De Le Wiki de Lug
Aller à la navigation Aller à la recherche
Modèle>Hlm Z.
(correction retour à la ligne)
Modèle>Hlm Z.
(correction du paramètre name)
Ligne 20 : Ligne 20 :
local frame = mw.getCurrentFrame()
local frame = mw.getCurrentFrame()
local fichierWiki = '[[Fichier:%s|%spx|link=%s|%s|%s|alt=%s]]'
local fichierWiki = '[[Fichier:%s|%spx|link=%s|%s|%s|alt=%s]]'
local argsId = args.id


iconeTitre
iconeTitre
Ligne 29 : Ligne 30 :
args.texte or 'Exemple de texte',
args.texte or 'Exemple de texte',
args.texte or 'Exemple de texte'))
args.texte or 'Exemple de texte'))
if not args.id then
local nsPage = mw.title.getCurrentTitle().namespace
if nsPage == 2 or nsPage == 3 then
argsId = args.image or 'Fairytale bookmark.png'
end
end


res
res
:wikitext(frame:extensionTag('indicator', tostring(iconeTitre), {
:wikitext(frame:extensionTag('indicator', tostring(iconeTitre), {
name = args.id or 'IDTidauto_' .. math.random(500)
name = argsId --args.id or 'IDTidauto_' .. math.random(500)
}))
}))



Version du 11 janvier 2015 à 14:26

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()
	local iconeTitre = mw.html.create()
	local frame = mw.getCurrentFrame()
	local fichierWiki = '[[Fichier:%s|%spx|link=%s|%s|%s|alt=%s]]'
	local argsId = args.id

	iconeTitre
 		: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 '',
			args.texte or 'Exemple de texte',
			args.texte or 'Exemple de texte'))

	if not args.id then
		local nsPage = mw.title.getCurrentTitle().namespace
		if nsPage == 2 or nsPage == 3 then
			argsId = args.image or 'Fairytale bookmark.png'
		end
	end

	res
		:wikitext(frame:extensionTag('indicator', tostring(iconeTitre), {
			name = argsId --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