no edit summary
(Created page with "-- This module provides easy processing of arguments passed to Scribunto from -- #invoke. It is intended for use by other Lua modules, and should not be -- called from #invoke...") |
|||
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
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
setmetatable(args, metatable)
local function mergeArgs(
--[[
-- Accepts multiple tables as input and merges their keys and values
-- into one table
--
-- values, which can be overwritten if they are 's' (soft).
--]]
for _, t in ipairs(tables) do
for key, val in
if metaArgs[key] == nil and nilArgs[key] ~= 'h' then
local tidiedVal = tidyVal(key, val)
if tidiedVal == nil then
nilArgs[key] =
else
metaArgs[key] = tidiedVal
for _, argTable in ipairs(argTables) do
local argTableVal = tidyVal(key, argTable[key])
if argTableVal
nilArgs[key] = true▼
metaArgs[key] = argTableVal
return argTableVal
end
end
return nil
end
--]]
metaArgs[key] = nil
nilArgs[key] =
else
metaArgs[key] = val
-- 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
|