Fandom

Narutopedia

Module:Main

6,205pages on
this wiki
Add New Page
Talk0

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.

-- Implements [[Template:Main]]
 
local p = {}
local err = require("Module:Error")
local yn = require("Module:Yesno")
 
local function link(l, t)
	return string.format("[[%s|%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
-- [[Category:Lua Modules]]

Also on Fandom

Random Wiki