Module:Main

-- Implements Template:Main

local p = {} local err = require("Module:Error")

local function link(l, t)	return string.format("%s%s", l, t and ("|"..t) or '') end

function p.main(frame) local args = frame:getParent.args local text = "Main article: " local mid

if not args[1] then return err("Main: No parameters supplied") end if not args[2] then return text..link(args[1], args["l1"] or args[1]) end -- Loop through the args local i = 1 text = "Main articles: " repeat

if args[i+1] then mid = args[i+2] and ", " or " and " else mid = "" end

text = text..link(args[i], args["l"..i] or args[i]) .. mid i = i + 1

until not args[i]

return text end

return p --