Modulus:scripts2/templates
Appearance
Documentation for this module may be created at Modulus:scripts2/templates/doc
local export = {}
function export.exists(frame)
local args = frame.args
local sc = args[1] or error("Script code has not been specified. Please pass parameter 1 to the module invocation.")
sc = require("Module:scripts").getByCode(sc)
if sc then
return "1"
else
return ""
end
end
function export.getByCode(frame)
local args = frame.args
local sc = args[1] or error("Script code (parameter 1) has not been specified.")
local itemname = args[2] or error("Function to call (parameter 2) has not been specified.")
sc = require("Module:scripts").getByCode(sc) or error("The script code '" .. sc .. "' is not valid.")
-- The item that the caller wanted to look up
if itemname == "getCanonicalName" then
return sc: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 sc:getOtherNames()[index] or ""
elseif itemname == "getCategoryName" then
return sc:getCategoryName()
elseif itemname == "countCharacters" then
local text = args[3] or ""
return sc:countCharacters(text)
else
error("Requested invalid item name \"" .. itemname .. "\".")
end
end
function export.getByCanonicalName(frame)
local args = frame.args
local sc = args[1] or error("Script name (parameter 1) has not been specified.")
sc = require("Module:scripts").getByCanonicalName(sc)
if sc then
return sc:getCode()
else
return "None"
end
end
return export