Difference between revisions of "Module:Distinguish/sandbox"

From blackwiki
Jump to navigation Jump to search
blackwiki>Nihiltres
m (Tweaks)
blackwiki>Andrybak
m (sync with live version)
Line 10: Line 10:
 
mArguments = require('Module:Arguments')
 
mArguments = require('Module:Arguments')
 
mTableTools = require('Module:TableTools')
 
mTableTools = require('Module:TableTools')
local args = mTableTools.compressSparseArray(mArguments.getArgs(frame))
+
local args = mArguments.getArgs(frame)
local text = args.text or args.t
+
local selfref = args.selfref
return p._distinguish(args, text, args.selfref)
+
local text = args.text
 +
args = mTableTools.compressSparseArray(args)
 +
return p._distinguish(args, text, selfref)
 
end
 
end
  
 
function p._distinguish(args, text, selfref)
 
function p._distinguish(args, text, selfref)
 
checkType("_distinguish", 1, args, 'table')
 
checkType("_distinguish", 1, args, 'table')
if #args == 0 and not text then
+
if #args == 0 and not text then return '' end
return mHatnote.makeWikitextError(
 
'No page names or text specified',
 
'Template:Distinguish#Errors'
 
)
 
end
 
 
local text = string.format(
 
local text = string.format(
 
'Not to be confused with %s.',
 
'Not to be confused with %s.',
 
text or mHatlist.orList(args, true)
 
text or mHatlist.orList(args, true)
 
)
 
)
local hnOptions = {selfref = selfref}
+
hnOptions = {selfref = selfref}
 
return mHatnote._hatnote(text, hnOptions)
 
return mHatnote._hatnote(text, hnOptions)
 
end
 
end
  
 
return p
 
return p

Revision as of 13:44, 4 July 2020

Documentation for this module may be created at Module:Distinguish/sandbox/doc

local mHatnote = require('Module:Hatnote')
local mHatlist = require('Module:Hatnote list')
local mArguments --initialize lazily
local mTableTools --initialize lazily
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local p = {}

function p.distinguish(frame)
	mArguments = require('Module:Arguments')
	mTableTools = require('Module:TableTools')
	local args = mArguments.getArgs(frame)
	local selfref = args.selfref
	local text = args.text
	args = mTableTools.compressSparseArray(args)
	return p._distinguish(args, text, selfref)
end

function p._distinguish(args, text, selfref)
	checkType("_distinguish", 1, args, 'table')
	if #args == 0 and not text then return '' end
	local text = string.format(
		'Not to be confused with %s.',
		text or mHatlist.orList(args, true)
	)
	hnOptions = {selfref = selfref}
	return mHatnote._hatnote(text, hnOptions)
end

return p