Difference between revisions of "Module:Sandbox/Tom Morris"

From blackwiki
Jump to navigation Jump to search
blackwiki>Tom Morris
(turning into link)
blackwiki>Tom Morris
(refactoring)
Line 2: Line 2:
  
 
p.spouse = function(frame)
 
p.spouse = function(frame)
     local entity = mw.wikibase.getEntity()
+
     local spouse_input = mw.text.trim(frame.args[1])
    local label = mw.wikibase.sitelink("Q" .. entity.claims.p26[0].mainsnak.datavalue.value["numeric-id"])
+
    if spouse_input == "PARAMETER_NOT_SET" then
    return "[[" .. label .. "]]"
+
        -- get from wikidata
 +
        local entity = mw.wikibase.getEntity()
 +
        local label = mw.wikibase.sitelink("Q" .. entity.claims.p26[0].mainsnak.datavalue.value["numeric-id"])
 +
        return "[[" .. label .. "]]"
 +
    else
 +
        return spouse_input
 +
    end
 
end
 
end
  
 
return p
 
return p

Revision as of 14: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])
    if spouse_input == "PARAMETER_NOT_SET" then
        -- get from wikidata
        local entity = mw.wikibase.getEntity()
        local label = mw.wikibase.sitelink("Q" .. entity.claims.p26[0].mainsnak.datavalue.value["numeric-id"])
        return "[[" .. label .. "]]"
    else
        return spouse_input
    end
end

return p