Module:Main

-- Implements Template:Main -- Source: http://naruto.wikia.com/wiki/Module:Main

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

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

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

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

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

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

until not yn(args[i])

return text end

return p --