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

De Lagny-sur-Marne Wiki
Aller à la navigation Aller à la recherche
0x010D (discussion | contributions)
Aucun résumé des modifications
0x010D (discussion | contributions)
correction retour à la ligne
Ligne 4 : Ligne 4 :
local args = {}
local args = {}
local argsParent = frame:getParent().args
local argsParent = frame:getParent().args
 
--Paramètres vides interprétés par Lua
--Paramètres vides interprétés par Lua
for cle, val in pairs(argsParent) do
for cle, val in pairs(argsParent) do
Ligne 11 : Ligne 11 :
end
end
end
end
 
return p._main(args)
return p._main(args)
end
end


function p._main(args)
function p._main(args)
local res = mw.html.create():newline()
local res = mw.html.create()
local span = mw.html.create('span')
local iconeTitre = mw.html.create()
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]]'
 
span
iconeTitre
  :wikitext(mw.ustring.format(fichierWiki,
  :wikitext(mw.ustring.format(fichierWiki,
args.image or 'Fairytale bookmark.png',
args.image or 'Fairytale bookmark.png',
Ligne 29 : Ligne 29 :
args.texte or 'Exemple de texte',
args.texte or 'Exemple de texte',
args.texte or 'Exemple de texte'))
args.texte or 'Exemple de texte'))
 
res
res
:wikitext(frame:extensionTag('indicator', tostring(span), {
:wikitext(frame:extensionTag('indicator', tostring(iconeTitre), {
name = args.id or 'IDTidauto_' .. math.random(500)
name = args.id or 'IDTidauto_' .. math.random(500)
}))
}))
 
if not args.id then
if not args.id then
res:wikitext('[[Catégorie:Page utilisant une icône de titre sans identifiant]]')
res:wikitext('[[Catégorie:Page utilisant une icône de titre sans identifiant]]')

Version du 31 décembre 2014 à 00:03

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 = '%s'

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'))

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

if not args.id then res:wikitext() end

return tostring(res) end

return p