Module:Families/templates
Appearance
local export = {}
function export.exists(frame)
local args = frame.args
local fam = args[1] or error("Family code has not been specified. Please pass parameter 1 to the module invocation.")
fam = require("Module:families").getByCode(fam)
if fam then
return "1"
else
return ""
end
end
function export.getByCode(frame)
local args = frame.args
local fam = args[1] or error("Family code (parameter 1) has not been specified.")
local itemname = args[2] or error("Function to call (parameter 2) has not been specified.")
fam = require("Module:families").getByCode(fam) or error("The family code '" .. fam .. "' is not valid.")
-- The item that the caller wanted to look up
if itemname == "getCanonicalName" then
return fam:getCanonicalName()
elseif itemname == "getOtherNames" then
local index = args[3]; if index == "" then index = nil end
index = tonumber(index or error("Numeric index of the desired item in the list (parameter 3) has not been specified."))
return fam:getOtherNames()[index] or ""
elseif itemname == "getFamily" then
return fam:getFamily():getCode()
elseif itemname == "getCategoryName" then
return fam:getCategoryName()
else
error("Requested invalid item name \"" .. itemname .. "\".")
end
end
function export.getByCanonicalName(frame)
local args = frame.args
local famname = args[1] or error("Family name has not been specified. Please pass parameter 1 to the module invocation.")
local fam = require("Module:families").getByCanonicalName(famname)
if fam then
return fam:getCode()
else
return ""
end
end
return export