Shortcuts: WD:SB, WD:SANDBOX

Module:Sandbox

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


Sandbox
Welcome to this Sandbox page, which allows you to carry out experiments. To edit, click here, or here for VisualEditor test; make your changes, and click the Save page button when finished. Please do not place copyrighted, offensive, or libelous content in the sandbox. If you want to test on an actual item, see Q4115189, Q13406268, Q15397819, Q112795079. Testing properties of each data type can be found in Category:Sandbox properties. If you want to experiment with creating new items and properties there's test.wikidata for you.

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