Shortcuts: WD:SB, WD:SANDBOX

Module:Sandbox

From Wikidata
Jump to navigation Jump to search
Lua
CodeDiscussionLinksLink count SubpagesDocumentationTestsResultsSandboxLive code All modules


Code

local p = {}
function p.hello(frame)
    return mw.title.getCurrentTitle()
end

function p.flag(frame)
	id = frame.args["id"]
	local bestStatement = mw.wikibase.getBestStatements(id, "P41")[1]["mainsnak"]["datavalue"]["value"]
	return bestStatement
end	

function p.nosubst(frame)
	return "{{sandbox}}"
end

function p.test(frame)
	local titles = {}
	while frame do
		local args = {}
		for arg in pairs(frame.args) do
			table.insert(args, arg)
		end
		table.insert(titles, {frame:getTitle(), args})
		frame = frame:getParent()
	end
	return mw.text.jsonEncode(titles)
end

return p