Module:Infobulle

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

local p = {}

function p._build(args)
	local text = args['texte'] or args[1] or 'Texte ?'
	local title = args['titre'] or args[2] or 'Infobulle ?'
	local link = args['lien'] or args[3]
	local style = args['style'] or ''
	
	local tooltip = mw.html.create( 'span' )
		:addClass( 'avt-tooltip' )
		:attr('style', style)
		:attr('title', title)
		:wikitext(text)
		:allDone()
	
	tooltip = tostring(tooltip)
	
	if link then
		tooltip = '[[' .. link .. '|' .. tooltip .. ']]'
	end
	
	return tooltip
end

function p.build(frame)
	local args = {}
	
	local argsParent = frame:getParent().args
	for cle, val in pairs(argsParent) do
		if val then
			args[cle] = mw.text.trim(val)
		end
	end
	
	return p._build(args)
end

return p