Modul:Redirect hatnote: Unterschied zwischen den Versionen
Updated with sandbox/testcases-tested behaviour that changes defaulting and adds tracking for a different wierd behaviour
(Added hack to categorize pages using odd edge-case behaviour) |
(Updated with sandbox/testcases-tested behaviour that changes defaulting and adds tracking for a different wierd behaviour) |
||
Zeile 86: | Zeile 86: | ||
-- phrase "For cats, see [[Felines]]".) | -- phrase "For cats, see [[Felines]]".) | ||
-- Returns a string, or nil if no use was specified. | -- Returns a string, or nil if no use was specified. | ||
-- The isFirst parameter is | -- The isFirst parameter is legacy, but partly maintained for its effect of | ||
-- | -- cancelling empty use items. | ||
useTable = useTable or {} | useTable = useTable or {} | ||
local use | local use | ||
Zeile 95: | Zeile 95: | ||
return nil | return nil | ||
elseif tonumber(useTable.use) == 1 then | elseif tonumber(useTable.use) == 1 then | ||
use = 'other uses' | --This is really strange behaviour, so it gets a category hack to see if it's actually being used. | ||
use = 'other uses[[Category:Hatnote templates using unusual parameters]]' | |||
else | else | ||
use = useTable.use | use = useTable.use | ||
end | end | ||
local pages = useTable.pages or {} | local pages = useTable.pages or {} | ||
redirect = redirect[1] or error( | |||
'no redirect was supplied', | |||
2 | |||
) | |||
pages[1] = pages[1] or redirect .. ' (disambiguation)' | |||
pages = mHatnote.formatPages(unpack(pages)) | pages = mHatnote.formatPages(unpack(pages)) | ||
pages = mw.text.listToText(pages) | pages = mw.text.listToText(pages) | ||
Zeile 146: | Zeile 138: | ||
if data[1] and data[1].use and data[1].use ~= 'other uses' then | if data[1] and data[1].use and data[1].use ~= 'other uses' then | ||
for i = 2, #data do | for i = 2, #data do | ||
text[#text + 1] = formatUseTable(data[i] or {}, false) | text[#text + 1] = formatUseTable(data[i] or {}, false, redirect) | ||
end | end | ||
end | end |