Difference between revisions of "Module:Other uses/sandbox"

From blackwiki
Jump to navigation Jump to search
blackwiki>Nihiltres
(Sandbox-testing an update)
 
blackwiki>Nihiltres
m (Derped on function to use and doubling up the wrapping)
Line 31: Line 31:
 
}
 
}
 
end
 
end
local text = mHatlist._forSee({
+
local text = mHatlist.forSeeTableToString({{
 
use = options.otherText and "other " .. options.otherText or nil,
 
use = options.otherText and "other " .. options.otherText or nil,
 
pages = args
 
pages = args
})
+
}})
 
return mHatnote._hatnote(text)
 
return mHatnote._hatnote(text)
 
end
 
end
  
 
return p
 
return p

Revision as of 20:04, 11 May 2016

Documentation for this module may be created at Module:Other uses/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 = {}

-- Produces standard {{other uses}} implementation
function p.otheruses(frame)
	mArguments = require('Module:Arguments')
	mTableTools = require('Module:TableTools')
	local args = mTableTools.compressSparseArray(mArguments.getArgs(frame))
	local title = mw.title.getCurrentTitle().text
	return p._otheruses(args, {title=title})
end

-- Main generator
function p._otheruses(args, options)
	--Type-checks and defaults
	checkType('_otheruses', 1, args, 'table', true)
	args = args or {}
	checkType('_otheruses', 2, options, 'table')
	if not (options.defaultPage or options.title) then
		error('No default title data provided in "_otheruses" options table', 2)
	end
	if #args == 0 then
		args = {
			options.defaultPage or
			mHatnote.disambiguate(options.title, options.disambiguator)
		}
	end
	local text = mHatlist.forSeeTableToString({{
		use = options.otherText and "other " .. options.otherText or nil,
		pages = args
	}})
	return mHatnote._hatnote(text)
end

return p