Module:Wikidata

From Random Island Wiki
Revision as of 15:01, 25 August 2013 by >RexxS (return an empty string instead of the message)
Jump to navigation Jump to search

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
        local entity = mw.wikibase.getEntity()
        if entity.claims.p26 ~= nil then
            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 ""
        end
    else
        return spouse_input
    end
end

return p