Module:For: Difference between revisions

213 bytes added ,  3 years ago
m
15 revisions imported from templatewiki:Module:For
m (Wrong category name)
m (15 revisions imported from templatewiki:Module:For)
 
(8 intermediate revisions by 6 users 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
return mHatnote._hatnote(
mHatlist.forSeeTableToString({{use = use, pages = pages}}),
{selfref = args.selfref}
)
) .. (
(use == 'other uses') and yesNo(args.category) and
use = use .. '[[Category:Hatnote templates using unusual parameters]]' or ''
)
end