Module:Link list: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
Content added Content deleted
(add option for list of formatted template links)
m (add "or" option instead of and)
 
Line 7: Line 7:
if index == 1 then
if index == 1 then
elseif index == #args then
elseif index == #args then
if f.args["or"]~=nil then
out = out .. ' and '
out = out .. ' or '
else
out = out .. ' and '
end
else
else
out = out .. ', '
out = out .. ', '

Latest revision as of 22:37, 18 June 2024

Documentation for this module may be created at Module:Link list/doc

local p = {}
-- generates a list like: "[[a]], [[b]] and [[c]]"
function p.listPages( f )
	local args = require('Module:ProcessArgs').merge()
	local out = ''
	for index, value in ipairs(args) do
		if index == 1 then
		elseif index == #args then
			if f.args["or"]~=nil then
				out = out .. ' or '
			else
				out = out .. ' and '
			end
		else
			out = out .. ', '
		end
		if f.args.template~=nil then
			out = out .. '<code>{{[[Template:' .. value .. '|' .. value .. ']]}}</code>'
		else
			out = out .. '[[' .. value .. ']]'
		end
	end
	return out
end
return p