Difference between revisions of "Module:Sandbox/Andy M. Wang"

From blackwiki
Jump to navigation Jump to search
blackwiki>Andy M. Wang
(skip first)
blackwiki>Andy M. Wang
m (which part)
Line 11: Line 11:
 
if type(k) == 'number' then
 
if type(k) == 'number' then
 
if k ~= 1 then
 
if k ~= 1 then
pages[k - 1] = v
+
pages[k] = v
 
end
 
end
 
end
 
end

Revision as of 06:33, 1 May 2016

Template:NOINDEX

A longer-term module sandbox for testing.


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 = {}
	for k, v in pairs(args) do
		if type(k) == 'number' then
			if k ~= 1 then
				pages[k] = v
			end
		end
	end
	return p._for(mw.title.getCurrentTitle().text, unpack(pages))
end

function p._for(titleText, ...)
	local links = mHatnote.formatPages(...)
	links = mw.text.listToText(links)
	local text = 'For ' .. links
	return mHatnote._hatnote(text)
end