FANDOM


local moduleIcon = {}
 
local iconData = require('module:Icon/data')
 
local errors = {
    ['iconDoesntExist'] = function(name)
        return '<span style=\'color:red;font-weight:normal;\'>Icon <span style=\'font-weight:bold;\'>'..name..'</span> doesn\'t exist!</span>[[Category:Nonexistent icon]]'
    end
}
 
function exists(str)
    return (str ~= nil and str ~= "")
end
 
function moduleIcon.icon(frame)
    local iconName = frame.args[1]
    local text = frame.args[2]
    local size = frame.args.size
    local link = frame.args.link
    local linkOnly = frame.args.linkOnly
 
    if (iconData[iconName] == nil) then
        return errors['iconDoesntExist'](iconName)
    end
 
    -- Dev commands
    if(exists(frame.args['get_link_text'])) then
        return iconData[iconName]['link']
    end
 
    if(exists(frame.args['get_image_name'])) then
        return iconData[iconName]['image']
    end
    -- END Dev Commands
 
    if (not exists(link)) then
        link = iconData[iconName]['link']
    end
 
    if (exists(linkOnly)) then
        if (exists(text)) then
            return "[["..link.."|"..text.."]]"
        else 
            return "[["..link.."]]"
        end
    end
 
    if (not exists(size)) then
        size = iconData[iconName]['size'] 
    end
 
    return createIcon(iconData[iconName]['image'], text, size, link)
 
end
 
function createIcon(icon, text, size, link)
    local iconString = '[[File:'..icon..'|'..size..'|link='..link..']]'
 
    if (exists(text)) then
        iconString = iconString .. ' [['..link..'|'..text..']]'    
    end
 
    return iconString
end
 
return moduleIcon

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.