Module:Wikidata: Difference between revisions
From Vigyanwiki
Template>RexxS (more unambiguous function name) |
Template>RexxS (Rename parameter value to something more illuminating) |
||
Line 3: | Line 3: | ||
p.getSpouse = function(frame) | p.getSpouse = function(frame) | ||
local spouse_input = mw.text.trim(frame.args[1] or "") | local spouse_input = mw.text.trim(frame.args[1] or "") | ||
if spouse_input == " | if spouse_input == "FETCH_WIKIDATA" then | ||
-- get from wikidata | -- get from wikidata | ||
local entity = mw.wikibase.getEntity() | local entity = mw.wikibase.getEntity() |
Revision as of 23:16, 25 August 2013
Documentation for this module may be created at Module:Wikidata/doc
local p = {}
p.getSpouse = function(frame)
local spouse_input = mw.text.trim(frame.args[1] or "")
if spouse_input == "FETCH_WIKIDATA" then
-- get from wikidata
local entity = mw.wikibase.getEntity()
local out = {}
for k, v in pairs(entity.claims.p26) do
out[#out + 1] = "[[" .. mw.wikibase.sitelink("Q" .. v.mainsnak.datavalue.value["numeric-id"]) .. "]]"
end
-- TODO: hlist return
return table.concat(out, ", ")
else
return spouse_input
end
end
return p