Jump to content

Module:Sandbox/Gnosygnu

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Gnosygnu (talk | contribs) at 04:42, 31 July 2015. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
--This Module is for Lua experimentation. No other pages refer to it.

local p = {}

function p.gsub_string(frame)
    local arg_1 = frame.args[1]
    local arg_2 = frame.args[2]
    local arg_3 = frame.args[3]
    local rv = ""
    rv = mw.ustring.gsub(arg_1, arg_2, arg_3)
    return rv
end

function p.wikibase_novalue(frame)
  local item = mw.wikibase.getEntityObject();
  local prop = item.claims[frame.args[2]];
  local rv = '';
  for _, statement in pairs( prop ) do
    local dv = statement.mainsnak.datavalue;
    if (dv == nil) then
      rv = rv .. ';nil';
    else
      rv = rv .. ';val';
    end
  end
  return rv
end


return p