Module:For: Difference between revisions

Content deleted Content added
m Wrong category name
don't add talk pages and pages in the user namespace to Category:Hatnote templates with errors – this is similar to Module:Other uses of and Module:Hatnote
 
(5 intermediate revisions by one other user not shown)
Line 2:
local mHatlist = require('Module:Hatnote list')
local mHatnote = require('Module:Hatnote')
local yesNo = require('Module:Yesno')
local p = {}
 
Line 13 ⟶ 14:
--Implements {{For}} but takes a manual arguments table
function p._For (args)
local use = args[1] --cases with parameter 1 unspecified should probably be flagged
if (not use == 'other uses') then
return mHatnote.makeWikitextError(
use = use .. '[[Category:Hatnote templates using unusual parameters]]'
'no context parameter provided. Use {{other uses}} for "other uses" hatnotes.',
'Template:For#Errors',
args.category
)
end
local pages = {}
function two (a, b, c) return a, b, 1 end --lets us run ipairs from 2
for k, v in two(ipairs(args)) do table.insert(pages, v) end
local title = mw.title.getCurrentTitle()
local skipCat = title.isTalkPage or title.namespace == 2 --don't categorise talk pages and userspace
use local oddCat = useskipCat and '' ..or '[[Category:Hatnote templates using unusual parameters]]'
local category = yesNo(args.category)
return mHatnote._hatnote(
mHatlist.forSeeTableToString({{use = use, pages = pages}}),
{selfref = args.selfref}
)
) .. (
(use == 'other uses') and ((category == true) or (category == nil)) and
oddCat or ''
)
end