Module:Technical reasons
Appearance
Implements {{technical reasons}}.
local mHatnote = require('Module:Hatnote')
local mHatlist = require('Module:Hatnote list')
local mArguments --initialize lazily
local mTableTools = require('Module:TableTools')
local p = {}
function p.technicalReasons (frame)
mArguments = require('Module:Arguments')
local args = mArguments.getArgs(frame)
return p._technicalReasons(args)
end
function p._technicalReasons (args)
--Gaps are suppressed!
args = mTableTools.compressSparseArray(args)
--Return an error if no redirect's provided
if #args == 0 then
return mHatnote.makeWikitextError(
'no redirect provided',
'Template:Technical reasons'
)
end
local from = 2
--Suppresses defaulting; every use requires a page or the for-see item
--doesn't display.
if #args > 3 and #args % 2 == 0 and
(#args < 5 or args[#args - 1] ~= 'and') then
args[#args] = nil
end
--if only two args, arg[1] is the use, arg[2] is the page, by evaluation offset.
if #args == 2 then from = 1 end
local technicalForm = 'For [[Wikipedia:Naming conventions (technical restrictions)#Forbidden characters|technical reasons]], "%s" redirects here.'
local forSee --nil by default to concat nicely if not present
if #args > 1 then forSee = mHatlist._forSee(args, from) end
local text = table.concat({string.format(technicalForm, args[1]), forSee}, ' ')
return mHatnote._hatnote(text)
end
return p