Jump to content

Module:Wikidata

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by RexxS (talk | contribs) at 17:06, 25 August 2013 (create a duplicate of Module:Sandbox/Tom Morris to debug). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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
        -- TODO: hlist return
        return table.concat(out, ", ")
    else
        return spouse_input
    end
end

return p