Module:Sandbox/User:Chen
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Sandbox/User:Chen/doc
--<nowiki>
local Enum = require("Module:Array")
local p = {}
function p.main(frame)
return tostring(mw.html.create("input")
:attr("type", "checkbox")
:css("background-color", "red"))
end
function p.thing(frame)
mw.logObject(frame.getParent(frame))
end
function p._0(frame)
return "==Test==\nStuff here"
end
function p._1(frame)
mw.logObject(getmetatable(frame:getParent().args))
end
function p._2(frame)
return "[[Category:Test|M]]"
end
function p.gsub(frame)
local args = frame.args
mw.logObject(frame)
mw.logObject(args)
mw.logObject(frame:getParent())
mw.logObject(frame:getParent().args)
local str = args[1]
local pattern = args[2]
local replacement = args[3]
return str:gsub(pattern, replacement)
end
function p._3(_frame)
local function sf(t)
if type(t) == "string" then
return t
else
return table.join(", ", t)
end
end
local query = {
'[[Item ID::>0]]',
'?Item ID'
}
query.limit = 10000
local smwdata = mw.smw.ask(query)
local data = {}
for _, item in ipairs(smwdata) do
table.insert(data, string.format("* %s", sf(item["Item ID"])))
end
return table.concat(data, "\n")
end
return p