Anonymous user
Module:Arguments: Difference between revisions
apply changes from sandbox - all tests pass
m (19 revisions imported from w:Module:Arguments: import code for updated template) |
(apply changes from sandbox - all tests pass) |
||
Line 46:
local function tidyValNoChange(key, val)
return val
local function matchesTitle(given, title)
local tp = type( given )
return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title
end
Line 82 ⟶ 87:
local title = parent:getTitle():gsub('/sandbox$', '')
local found = false
if
found = true▼
for _,v in pairs(options.wrappers) do
if matchesTitle(v
found = true
break
end
end
▲ elseif options.wrappers == title then
▲ found = true
end
-- We test for false specifically here so that nil (the default) acts like true.
if found or options.frameOnly == false then
Line 165 ⟶ 170:
setmetatable(args, metatable)
local function mergeArgs(
--[[
-- Accepts multiple tables as input and merges their keys and values
-- into one table
--
--
--]]
for _, t in ipairs(tables) do
for key, val in
if metaArgs[key] == nil and nilArgs[key] ~= 'h' then
local tidiedVal = tidyVal(key, val)
Line 263 ⟶ 267:
-- Called when pairs is run on the args table.
if not metatable.donePairs then
mergeArgs(
metatable.donePairs = true
end
return pairs(metaArgs)
end
local function inext(t, i)
-- This uses our __index metamethod
local v = t[i + 1]
if v ~= nil then
return i + 1, v
end
end
metatable.__ipairs = function (t)
-- Called when ipairs is run on the args table.
return inext, t, 0
▲ end
end
|