Site Notice

hello, world

Difference between revisions of "Module:UserFunctions"

From Project-EPB Commons
(Created page with "local p = {} local getArgs = require('Module:Arguments').getArgs function p.main(frame) local args = getArgs(frame) local type = args[1] or args['type'] -- 识别功能...")
 
([InPageEdit] 没有编辑摘要)
Line 10: Line 10:
 
   elseif type == 'usergroup' then
 
   elseif type == 'usergroup' then
 
     p.usergroup(frame)
 
     p.usergroup(frame)
 +
  else
 +
    return '<span class="error" data-userfunction="no-such-function">UserFunctions脚本错误:没有功能' .. args[1] .. '</span>'
 
   end
 
   end
 
end
 
end

Revision as of 17:04, 3 March 2020

https://common.epb.wiki/index.php?title=Module:UserFunctions/doc&action=edit

UserFunctions脚本错误:没有功能123

Lua error at line 19: attempt to index field 'create' (a nil value).

Lua error at line 25: attempt to index field 'create' (a nil value).

UserFunctions脚本错误:没有功能第一


local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.main(frame)
  local args = getArgs(frame)
  local type = args[1] or args['type']
  -- 识别功能
  if type == 'username' then
    p.username()
  elseif type == 'usergroup' then
    p.usergroup(frame)
  else
    return '<span class="error" data-userfunction="no-such-function">UserFunctions脚本错误:没有功能' .. args[1] .. '</span>'
  end
end

-- 用户名
function p.username()
  local html = mw.create.html()
  local resHtml = html:tag('span'):addClass('UserFunctions'):attr('data-type', 'username'):wikitext('加载中'):done()
  return tostring(resHtml)
end

function p.usergroup()
  local html = mw.create.html()
  local resHtml = html:tag('span'):addClass('UserFunctions'):attr('data-type', 'usergroup'):wikitext('加载中'):done()
  return tostring(resHtml)
end

return p