Module:TORcite

-- This module implements Template:TORcite.

local p = {}

local function check(str) if str == nil then str = "" end return str end function p.citation(args, data) local image = " " local game = "Star Wars: The Old Republic&mdash;" if args.exp then game = data.expansions[args.exp] end

local mode = data.modes[args.type] local source = check(mode.a) .. check(args[1]) .. check(mode.b) .. check(args[2]) .. check(mode.c) .. check(args[3]) local result = image .. game .. source return result end

function p.main(frame) local data = mw.loadData('Module:TORcite/data') local args = {} for k, v in pairs(frame:getParent.args) do 		v = v:match('^%s*(.-)%s*$') -- trim whitespace if v ~= '' then args[k] = v		end end return p.citation(args, data) end

return p