Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Arguments: Difference between revisions

Content added Content deleted
(mirror latest changes)
(fix bug where explicitly deleted args were still appearing when iterated over with pairs or ipairs - code courtesy of User:Jackmcbarn)
Line 92: Line 92:
found = true
found = true
end
end

-- We test for false specifically here so that nil (the default) acts like true.
-- We test for false specifically here so that nil (the default) acts like true.
if found or options.frameOnly == false then
if found or options.frameOnly == false then
Line 170: Line 170:
-- into one table using the specified iterator. If a value is already
-- into one table using the specified iterator. If a value is already
-- present it is not overwritten; tables listed earlier have precedence.
-- present it is not overwritten; tables listed earlier have precedence.
-- We are also memoizing nil values, but those values can be
-- We are also memoizing nil values, which can be overwritten if they
-- overwritten.
-- are 's' (soft).
--]]
--]]
for _, t in ipairs(tables) do
for _, t in ipairs(tables) do
for key, val in iterator(t) do
for key, val in iterator(t) do
if metaArgs[key] == nil then
if metaArgs[key] == nil and nilArgs[key] ~= 'h' then
local tidiedVal = tidyVal(key, val)
local tidiedVal = tidyVal(key, val)
if tidiedVal == nil then
if tidiedVal == nil then
nilArgs[key] = true
nilArgs[key] = 's'
else
else
metaArgs[key] = tidiedVal
metaArgs[key] = tidiedVal
Line 219: Line 219:
for _, argTable in ipairs(argTables) do
for _, argTable in ipairs(argTables) do
local argTableVal = tidyVal(key, argTable[key])
local argTableVal = tidyVal(key, argTable[key])
if argTableVal == nil then
if argTableVal ~= nil then
nilArgs[key] = true
else
metaArgs[key] = argTableVal
metaArgs[key] = argTableVal
return argTableVal
return argTableVal
end
end
end
end
nilArgs[key] = 'h'
return nil
return nil
end
end
Line 255: Line 254:
--]]
--]]
metaArgs[key] = nil
metaArgs[key] = nil
nilArgs[key] = true
nilArgs[key] = 'h'
else
else
metaArgs[key] = val
metaArgs[key] = val
Cookies help us deliver our services. By using our services, you agree to our use of cookies.