Halo Esports Wiki

We are currently performing extensive maintenance to this wiki and as a result there will likely be errors. Please be patient while we work to fix all problems.

READ MORE

Halo Esports Wiki
Advertisement
Halo Esports Wiki

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

local util_args = require("Module:ArgsUtil")
local util_text = require('Module:TextUtil')

local p = {}

function p.makeBox(data)
	local title = mw.title.getCurrentTitle().prefixedText
	local links = {}
	for k, v in ipairs(data.replace) do
		link = data.targetpage and data.targetpage[k] or string.gsub(title,
			util_text.escape(data.find[k] or data.find[1]),
			util_text.escape(data.replace[k]))
		display = data.display and data.display[k] or string.format('View the corresponding %s page',(data.tournament and data.tournament[k] or ''))
		links[k] = string.format('[[%s|%s]]', link, display)
	end
	
	local tbl = mw.html.create('div'):addClass('correspondingpagebox')
	tbl:wikitext(table.concat(links,' | '))
	return tostring(tbl)
end

function p.main(frame)
	local args = util_args.merge()
	for k, v in pairs(args) do
		args[k] = util_text.split(args[k], args.sep)
		for k2, v2 in ipairs(args[k]) do
			args[k][k2] = mw.text.trim(v2)
		end
	end
	return p.makeBox(args)
end
return p
Advertisement