Модуль:Icons

Материал из Викимультии — энциклопедии мультипликации
Перейти к навигации Перейти к поиску


Документация
-- [[Template:Icons]]
local p = {}
local data = mw.loadData('Module:Icons/data')

-- Generates the ending part
function p.main(frame)
	local args = frame:getParent().args
	local type = mw.ustring.lower(args[2])
	local name = mw.ustring.lower(args[1])
	local size = args.size or "18"
	local typeData
	local typeName
	
    if data[type] then
    	typeData=data[type]
    	
    	if typeData[name] then
    		typeName=typeData[name]
    		
    		if typeName.property then
    			if typeName.category then
		        	return string.format(
		        		"[[%s|%spx|link=|%s]]",
		        		typeName.image,
		        		size,
		        		typeName.text or ''
		        	)..frame:preprocess("{{#set:"..typeName.property.."="..name.."}}")..frame:preprocess("{{#ifeq:{{NAMESPACE}}||[[Category:"..typeName.category.."]]}}")
    			else
		        	return string.format(
		        		"[[%s|%spx|link=|%s]]",
		        		typeName.image,
		        		size,
		        		typeName.text or ''
		        	)..frame:preprocess("{{#set:"..typeName.property.."="..name.."}}")
    			end
	        else
    			if typeName.category then
		        	return string.format(
		        		"[[%s|%spx|link=|%s]]",
		        		typeName.image,
		        		size,
		        		typeName.text or ''
		        	)..frame:preprocess("{{#ifeq:{{NAMESPACE}}||[[Category:"..typeName.category.."]]}}")
    			else
		        	return string.format(
		        		"[[%s|%spx|link=|%s]]",
		        		typeName.image,
		        		size,
		        		typeName.text or ''
		        	)
    			end
    		end
    	end
    end
    
    return ""
end

return p