Module:Sandbox/Greenbreen/Toy
Appearance
(Redirected from Module:User:Greenbreen/Sandbox/Toy)
local p = {}
-- Core worker (logic only)
function p._compute(args)
-- raw input dump
if args.debug == "dump" then
return "<pre>" .. mw.dumpObject(args) .. "</pre>"
end
-- argument checking
if not args.x then
error("Missing required parameter |x=")
end
local x = tonumber(args.x)
if not x then
error("Parameter |x= must be numeric, got: " .. args.x)
end
local y = x * 2
-- optional debug output
if args.debug == "value" then
return "DEBUG: x=" .. x .. ", y=" .. y
end
return "Result: " .. y
end
-- Template entry point
function p.main(frame)
return p._compute(frame.args)
end
return p