Leaguepedia | League of Legends Esports Wiki
Advertisement
Leaguepedia | League of Legends Esports Wiki

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

local util = require('Module:Util')

local p = {}
function p.main(frame)
	if frame == mw.getCurrentFrame() then
		args = require('Module:ProcessArgs').merge(true)
	else
		frame = mw.getCurrentFrame()
	end
	local title = mw.title.getCurrentTitle().prefixedText
	local links = {}
	local sep = args.sep or ','
	
	for k, v in pairs(args) do
		args[k] = mw.text.split(args[k],sep)
		for k2, v2 in ipairs(args[k]) do
			args[k][k2] = mw.text.trim(v2)
		end
	end	
	for k, v in ipairs(args.replace) do
		link = args.targetpage[k] or string.gsub(title,
			util.escape(args.find[i] or args.find[1]),
			util.escape(args.replace[i]))
		display = args.display[i] or string.format('View the corresponding %s page',args.tournament[i])
		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
return p