模組:Indicator

被永久保护的模块
维基百科,自由的百科全书
文档图示 模块文档[创建]
local getArgs = require('Module:Arguments').getArgs
local p = {}
 
function p.main(frame)
	local args = getArgs(frame)
	local text = ''
	
	if args.image then
		text = '[[File:' .. args.image .. '|' .. (args.size or '24px') .. '|' .. args.alt .. '|link=' .. args.link .. ']]'
	end
	if args.text  then
		local temptext = args.text
		if args.fontsize then
			temptext = tostring( mw.html.create( 'span' ):css( 'font-size', args.fontsize ):wikitext( args.text ) )
		end
		text = text .. temptext
	end
	
	text = tostring( mw.html.create( 'div' ):attr{title=args.title, class=args.class}:wikitext( text ) )
	
	return text  == '' and '' or frame:extensionTag{
		name = 'indicator',
		content = text,
		args = { name = string.format( '%x', require( 'Module:Crc32lua' ).crc32( text ) ) },
	}
end

return p