Jump to content

Module:User:Mr. Stradivarius/icon

From Wikipedia, the free encyclopedia
-- This module implements {{icon}}.

local getArgs = require('Module:Arguments').getArgs
local data = mw.loadData('Module:User:Mr. Stradivarius/icon/data')

local p = {}

function p.main(frame)
	local args = getArgs(frame)
	local code = args[1]
	return p._main(code)
end

function p._main(code)
	-- Look the icon up in the icons table.
	local icons = data.icons
	local icon = icons[code]
	if icon then
		-- We found the icon first time, so return it.
		return icon
	else
		-- See if we were passed an alias and return the icon for that alias if everything checks out.
		code = data.aliases[code]
		if code then
			icon = icons[code]
			if icon then
				return icon
			end
		end
	end
	-- If all else fails, return the default value.
	return '[[File:Symbol question.svg|16px|link=]]'
end

return p