Module:Arguments:修订间差异
删除的内容 添加的内容
zhwiki>Xiplus-abot 小 已保护“Module:Arguments”:高風險模板:3971931引用<!-- 機器人3 -->([编辑=仅允许管理员](无限期)[移动=仅允许管理员](无限期)) |
小 导入1个版本 |
||
| (未显示同一用户的1个中间版本) | |||
第47行:
return val
end
function arguments.getArgs(frame, options)
第60行 ⟶ 第53行:
frame = frame or {}
options = options or {}
if options.translate[k] ~= k then▼
else▼
end▼
--[[
第114行 ⟶ 第82行:
local title = parent:getTitle():gsub('/sandbox$', '')
local found = false
if
found = true▼
for _,v in pairs(options.wrappers) do
if
found = true
break
end
end
▲ found = true
end
-- We test for false specifically here so that nil (the default) acts like true.
if found or options.frameOnly == false then
第149行 ⟶ 第117行:
luaArgs = frame
end
-- Set the order of precedence of the argument tables. If the variables are
-- nil, nothing will be added to the table, which is how we avoid clashes
-- between the frame/parent args and the Lua args.
local argTables = {fargs}
argTables[#argTables + 1] = pargs
第197行 ⟶ 第165行:
setmetatable(args, metatable)
local function mergeArgs(iterator, tables)
--[[
-- Accepts multiple tables as input and merges their keys and values
-- into one table using the specified iterator. If a value is already
-- present it is not overwritten; tables listed earlier have precedence.
-- We are also memoizing nil values, but those values can be
-- overwritten.
--]]
for _, t in ipairs(tables) do
for key, val in
if metaArgs[key] == nil
local tidiedVal = tidyVal(key, val)
if tidiedVal == nil then
nilArgs[key] =
else
metaArgs[key] = tidiedVal
第242行 ⟶ 第211行:
-- must be nil.
--]]
local val = metaArgs[key]
if val ~= nil then
第253行 ⟶ 第219行:
for _, argTable in ipairs(argTables) do
local argTableVal = tidyVal(key, argTable[key])
if argTableVal
metaArgs[key] = argTableVal
return argTableVal
end
end
▲ nilArgs[key] = 'h'
return nil
end
第265行 ⟶ 第232行:
-- This function is called when a module tries to add a new value to the
-- args table, or tries to change an existing value.
if options.readOnly then
error(
第291行 ⟶ 第255行:
--]]
metaArgs[key] = nil
nilArgs[key] =
else
metaArgs[key] = val
end
end
第318行 ⟶ 第264行:
-- Called when pairs is run on the args table.
if not metatable.donePairs then
mergeArgs(pairs, argTables)
metatable.donePairs = true
metatable.doneIpairs = true
end
return
end
-- Called when ipairs is run on the args table.▼
if not metatable.doneIpairs then
mergeArgs(ipairs, argTables)
metatable.doneIpairs = true
end
return ipairs(metaArgs)
▲ -- Called when ipairs is run on the args table.
end
| |||