Module:Factions

-- @name: Factions Module @author: Unai01 @desc: It shows which factions sponsor the article via the tag -- local factions = {} local userError = require("Dev:User error") local dataFactions = mw.loadData('Módulo:Factions/datos')

function factions.main(frame) local data = ' ' for k,v in pairs(frame:getParent.args) do       local faction = dataFactions[v:lower] if faction~=nil then data = data .. (           factions.genTab( v .. '‍',               faction.image, faction.link , faction["description"] )        or '') else userError("Data not found") end end return frame:preprocess(data .. ' ') end

function factions.genTab(title, image, link, desc) local table = mw.html.create( 'table' ) table:tag('td') :css('width', '5%') :css('text-align', 'center') :wikitext('') table:tag('td') :css('text-align', 'center') :wikitext(desc) return title .. '=' .. tostring( table ) .. '\n|-|' end

function factions.test(frame) return dataFactions[frame.args[1]:lower].link end

return factions