Wookieepedia

READ MORE

Wookieepedia
Advertisement
Wookieepedia

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

-- This module implements [[Template:Main]].

local p = {}

function p._main(args)
	args[1] = args[1] or '{{{1}}}'
	local links = {}
	for i, v in ipairs(args) do
		links[i] = string.format(
			'[[%s|%s]]',
			v,
			args['l' .. i] or v:gsub("/Legends", "")
		)
	end
	local prefix
	if #links > 1 then
		prefix = 'Main articles'
	else
		prefix = 'Main article'
	end
	links = mw.text.listToText(links)
	return string.format(
		'<div class="noprint rellink">[[File:Blue Glass Arrow.svg|20px|link=]] %s: %s</div>',
		prefix, links
	)
end

function p.main(frame)
	local args = {}
	for k, v in pairs(frame:getParent().args) do
		v = v:match('^%s*(.-)%s*$') -- trim whitespace
		if v ~= '' then
			args[k] = v
		end
	end
	return p._main(args)
end

return p
Advertisement