De neikommende dokumintaasje stiet op Module:relat-top/dokumintaasje. [bewurkje]

Generearet in part fan 'e tekst mei opmaak fan Berjocht:relat-top.


p = {}

function p.main(frame)
	local args = frame:getParent().args
	local count = args["kolom"] or "3"
	
	if count == "" then
		count = "3"
	end
	
	local m_links = require("Module:links")
	local basic_link = false
	local lang = args["lang"] or "fy"
	local sc = args["sc"]
	
	if lang == "fy" then
		basic_link = true
	elseif sc then
		sc = require("Module:scripts").getByCode(sc) or error('De skriftkoade "' .. sc .. '" is net jildich.')
	end
	
	lang = require("Module:languages").getByCode(lang) or require("Module:languages").err(lang, "lang")
	
	local text = ""
	local relat = {"synon", "anton", "earder", "letter", "hjoed", "homof", "deriv", "compos", "hyper",
					"hypon", "holon", "meron", "relat"}
	
	for k, v in ipairs(relat) do
		if args[v] ~= "" and args[v] ~= nil then
			local terms = mw.text.split(args[v], "%s*,%s*")
			local test = "row"
			local linkpfx = ", "
			local linksfx = ""
			local linker = ""
			local links = ""
			
			if #terms > 5 then
				test = "cols"
				linkpfx = "<dd>"
				linksfx = "</dd>"
			end
			
			for key, value in ipairs(terms) do
				if value == "" then
					error('De parameter "' .. v .. '" befettet ûnjildige ynfier.')
				end
				
				if basic_link then
					linker = m_links.language_link({ term = value, lang = lang }, false)
				else
					linker = m_links.full_link({ term = value, lang = lang, sc = sc, tr = "-" }, nil, false)
				end
				
				links = links .. linkpfx .. linker .. linksfx
			end
			
			local cases = {
				cols = '</li></ul><div style="column-count:' .. count .. ';-moz-column-count:' .. count ..
						';-webkit-column-count:' .. count .. ';"><dl>' .. links .. '</dl></div>',
				default = ' ' .. links:gsub("^, ", "") .. '.</li></ul>',
			}
			
			text = text .. '<div><ul><li><span title="' .. v .. '">' .. frame:expandTemplate{ title = "Berjocht:" .. v } ..
					'</span>:' .. (cases[test] or cases["default"]) .. '</div>'
		end
	end
	
	return text
end

return p