Module:No ping: Difference between revisions

From Meta Wiki
Jump to navigation Jump to search
m>Mr. Stradivarius
create replacement for Template:Noping
 
m>Mr. Stradivarius
m Protected Module:No ping: High-risk Lua module ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite))
(No difference)

Revision as of 13:50, 12 February 2014

Documentation for this module may be created at Module:No ping/doc

-- This module implements {{noping}}.

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	return p._main(args)
end

function p._main(args)
	local ret = {}
	local fullUrl = mw.uri.fullUrl
	local format = string.format
	for i, username in ipairs(args) do
		local url = fullUrl('User:' .. username)
		url = tostring(url)
		local label = args['label' .. tostring(i)]
		url = format('[%s %s]', url, label or username)
		ret[#ret + 1] = url
	end
	ret = mw.text.listToText(ret)
	ret = '<span class="plainlinks">' .. ret .. '</span>'
	return ret
end

return p