Module:Link list: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
Content added Content deleted
(Created page with "local p = {} -- generates a list like: "a, b and c" function p.listPages( f ) local args = require('Module:ProcessArgs').merge(true) local out = '' for index, value in ipairs(args) do if index == 1 then elseif index == #args then out = out .. ' and ' else out = out .. ', ' end out = out .. '' .. value .. '' end return out end return p")
 
m (add "or" option instead of and)
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
-- generates a list like: "[[a]], [[b]] and [[c]]"
-- generates a list like: "[[a]], [[b]] and [[c]]"
function p.listPages( f )
function p.listPages( f )
local args = require('Module:ProcessArgs').merge(true)
local args = require('Module:ProcessArgs').merge()
local out = ''
local out = ''
for index, value in ipairs(args) do
for index, value in ipairs(args) do
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 .. ', '
end
end
if f.args.template~=nil then
out = out .. '[[' .. value .. ']]'
out = out .. '<code>{{[[Template:' .. value .. '|' .. value .. ']]}}</code>'
else
out = out .. '[[' .. value .. ']]'
end
end
end
return out
return 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