Difference between revisions of "Module:Sandbox/Andy M. Wang"
Jump to navigation
Jump to search
blackwiki>Andy M. Wang (get title text) |
blackwiki>Andy M. Wang (disambig) |
||
| Line 22: | Line 22: | ||
local links = mHatnote.formatPages(...) | local links = mHatnote.formatPages(...) | ||
links = mw.text.listToText(links) | links = mw.text.listToText(links) | ||
| − | if links == | + | if links == '' then |
| − | links = mw.frame.getCurrentTitle().text | + | links = mw.frame.getCurrentTitle().text .. ' (disambiguation)' |
end | end | ||
local text = 'For ' .. firstArg .. ', see ' .. links .. '.' | local text = 'For ' .. firstArg .. ', see ' .. links .. '.' | ||
Revision as of 06:47, 1 May 2016
local mHatnote = require('Module:Hatnote')
local mArguments -- lazily initialise
local p = {}
function p.forfun(frame)
mArguments = require('Module:Arguments')
local args = mArguments.getArgs(frame, {parentOnly = true})
local pages = {}
local firstArg = (args[1] and args[1]) or 'other uses'
for k, v in pairs(args) do
if type(k) == 'number' then
if k ~= 1 then
pages[k - 1] = v
end
end
end
return p._for(mw.title.getCurrentTitle().text, firstArg, unpack(pages))
end
function p._for(titleText, firstArg, ...)
local links = mHatnote.formatPages(...)
links = mw.text.listToText(links)
if links == '' then
links = mw.frame.getCurrentTitle().text .. ' (disambiguation)'
end
local text = 'For ' .. firstArg .. ', see ' .. links .. '.'
return mHatnote._hatnote(text)
end
return p