Die Dokumentation für dieses Modul kann unter Modul:Ünnerdelen/Doku erstellt werden

local p = {}

function p.list(frame)
	local id = frame.args["id"]
	local entity = mw.wikibase.getEntity(id)
	local source = ""
	if entity then
		local claims150 = entity.claims[mw.wikibase.resolvePropertyId('P150')]
		if claims150 then
			local args = {}
			args["Typ"] = frame:getParent().args["Typ"] or ""
			args["mitWapen"] = frame:getParent().args["mitWapen"] or ""
			args["mitFlagg"] = frame:getParent().args["mitFlagg"] or ""
			args["mitKoort"] = frame:getParent().args["mitKoort"] or ""
			args["mitHööftoort"] = frame:getParent().args["mitHööftoort"] or ""
			args["mitNummer"] = frame:getParent().args["mitNummer"] or ""
			args["Klammer"] = frame:getParent().args["Klammer"] or ""
			local qid
			for idx, claim in pairs(claims150) do
				qid = claim.mainsnak.datavalue.value.id
				args["1"] = qid
				args["Nummer"] = idx
				source = source .. frame:expandTemplate{ title = 'Ünnerdelen/Reeg', args = args } .. "\n"
			end
			local number = frame:getParent().args["Tall"] or nil
			if number and #claims150 ~= tonumber(number) then
				source = "[[Kategorie:Tall Ünnerafdelen nich richtig]]\n" .. source
			end
		end
	end
	return source
end

function p.disambiguate(frame)
	local title = frame.args[1] or ""
	local parentheses = frame.args[2] or ""
	local entity = mw.wikibase.getEntity(mw.wikibase.getEntityIdForTitle(title))
	if entity then
		local claims31 = entity.claims[mw.wikibase.resolvePropertyId('P31')]
		if claims31 then
			for idx, claim in pairs(claims31) do
				if claim.mainsnak.datavalue.value.id == "Q4167410" then
					if parentheses then
						return title .. " (" .. parentheses .. ")|" .. title
					else
						return title
					end
				end
			end
		end
	end
	return title
end

return p