Module:List: Difference between revisions

From NPOWiki
Jump to navigation Jump to search
(probably not going to use most of these options ever, but here it is)
 
No edit summary
 
Line 41: Line 41:
for i, arg in ipairs(args) do
for i, arg in ipairs(args) do
if defArg(arg) then
if defArg(arg) then
arg = mw.text.trim(arg)
if nowrap then
if nowrap then
arg = '<span style="white-space:nowrap;">' .. arg .. '</span>'
arg = '<span style="white-space:nowrap;">' .. arg .. '</span>'

Latest revision as of 03:28, 22 August 2020

Documentation [edit]

This page is a stub - it only covers the very basics of its subject. More information should be added to make the page informative and useful. If no more information is available, the page should be considered for a merge, redirect, or deletion.

Details: documentation to be written

If you can correct the issue, please edit the page to do so, then remove this notice.
Please see Template:List for usage information. Use the template rather than invoking the module.

The above documentation is transcluded from Module:List/doc.

local p = {}

local function defArg(arg)
	return arg and mw.text.trim(arg) ~= ''
end

function p.main(frame)
	return p.call(frame:getParent().args)
end

function p.call(args)
	local code = ''
	local nowrap = defArg(args.nowrap)
	local sep = '&bull;'
	local spacebefore = true
	local spaceafter = true
	
	if defArg(args.nospace) then
		spacebefore = false
		spaceafter = false
	else
		if defArg(args.nospacebefore) then
			spacebefore = false
		end
		if defArg(args.nospaceafter) then
			spaceafter = false
		end
	end
	if defArg(args.sep) then
		sep = mw.text.trim(args.sep)
	elseif defArg(args.nosep) then
		sep = ''
	end
	if spacebefore then
		sep = ' ' .. sep
	end
	if spaceafter then
		sep = sep .. ' '
	end
	
	for i, arg in ipairs(args) do
		if defArg(arg) then
			arg = mw.text.trim(arg)
			if nowrap then
				arg = '<span style="white-space:nowrap;">' .. arg .. '</span>'
			end
			if code == '' then
				code = code .. arg
			else
				code = code .. sep .. arg
			end
		end
	end
	return code
end

return p