Difference between revisions of "Module:Sandbox/Tom Morris"
Jump to navigation
Jump to search
blackwiki>Tom Morris (expanding to deal with multiple spouses) |
blackwiki>Tom Morris (fixery) |
||
| Line 6: | Line 6: | ||
-- get from wikidata | -- get from wikidata | ||
local entity = mw.wikibase.getEntity() | local entity = mw.wikibase.getEntity() | ||
| − | |||
local out = {} | local out = {} | ||
for k, v in pairs(entity.claims.p26) do | for k, v in pairs(entity.claims.p26) do | ||
| − | out[#out + 1] = "[[" .. mw.wikibase.sitelink(v.mainsnak.datavalue.value["numeric-id"]) .. "]]" | + | out[#out + 1] = "[[" .. mw.wikibase.sitelink("Q" .. v.mainsnak.datavalue.value["numeric-id"]) .. "]]" |
end | end | ||
return table.concat(out, ", ") | return table.concat(out, ", ") | ||
Revision as of 15:15, 19 May 2013
Documentation for this module may be created at Module:Sandbox/Tom Morris/doc
local p = {}
p.spouse = function(frame)
local spouse_input = mw.text.trim(frame.args[1] or "")
if spouse_input == "PARAMETER_NOT_SET" 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
return table.concat(out, ", ")
else
return spouse_input
end
end
return p