Jump to content

Module:category tree/templates

Wiktionary වෙතින්

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

function export.exists(frame)
	local params = {
		["template"] = {required = true},
		["code"] = {},
		["label"] = {},
		["sc"] = {},
	}
	
	local args = require("Module:parameters").process(frame.args, params)
	
	local info = {code = args["code"], label = args["label"], sc = args["sc"]}
	local submodule = require("Module:category tree/" .. args["template"])
	local obj = submodule.new(info)
	
	return (obj ~= nil and "1" or "")
end

function export.get_item(frame)
	local params = {
		[1] = {required = true},
		["template"] = {required = true},
		["code"] = {},
		["label"] = {},
		["sc"] = {},
	}
	
	local args = require("Module:parameters").process(frame.args, params)
	
	local info = {code = args["code"], label = args["label"], sc = args["sc"]}
	local submodule = require("Module:category tree/" .. args["template"])
	local obj = submodule.new(info)
	
	local item = args[1]
	
	if item:find("^umbrella_") then
		item = item:gsub("^umbrella_", "")
		obj = obj:getUmbrella()
	end
	
	if obj and obj[item] then
		ret = obj[item](obj)
	else
		error("The requested data item \"" .. item .. "\" is not recognized.")
	end
	
	if not ret then
		return ""
	else
		return ret
	end
end

return export
"https://si.wiktionary.org/w/index.php?title=Module:category_tree/templates&oldid=23305" වෙතින් සම්ප්‍රවේශනය කෙරිණි