Module:Wikidata: Difference between revisions

From Random Island Wiki
Jump to navigation Jump to search
>RexxS
(create a duplicate of Module:Sandbox/Tom Morris to debug)
 
>RexxS
(more unambiguous function name)
Line 1: Line 1:
local p = {}
local p = {}


p.spouse = 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 == "PARAMETER_NOT_SET" then
     if spouse_input == "PARAMETER_NOT_SET" then

Revision as of 13:14, 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 == "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
        -- TODO: hlist return
        return table.concat(out, ", ")
    else
        return spouse_input
    end
end

return p