Module:UserLinks/sandbox: Difference between revisions

Content deleted Content added
update the p.linktable function to use the new links table
take the easy way out - copy all the links into the links table, then use next on that
Line 59:
end
return extraLinkFunctions
end
 
local function addExtraLink(code, func)
local success, link = linkFunctionpcall(func, snippets)
if success and type(link) == 'string' then
links[code] = link
end
end
 
Line 78 ⟶ 85:
local extraLinkFunction = extraLinkFunctions[code]
if type(extraLinkFunction) == 'function' then
link =addExtraLink(code, extraLinkFunction(snippets)
links[code] = link
end
end
Line 86 ⟶ 92:
end,
__pairs = function ()
extraLinkFunctions = getExtraLinkFunctions()
return function (t, key)
if extraLinkFunctions then
local nextBuiltInKey, linkFunction = next(linkFunctions, key)
for code, func in pairs(extraLinkFunctions) do
if linkFunction then
if validateCode(nextKeycode) and type(extraLinkFunctionfunc) == 'function' then
local link = linkFunction(snippets)
addExtraLink(code, func)
links[nextBuiltInKey] = link
return nextBuiltInKey, link
else
extraLinkFunctions = getExtraLinkFunctions()
if extraLinkFunctions then
local nextExtraKey, extraLinkFunction = next(extraLinkFunctions, key)
if validateCode(nextKey) and type(extraLinkFunction) == 'function' then
local link = extraLinkFunction(snippets)
links[nextExtraKey] = link
return nextExtraKey, link
end
end
end
end
return nil, nil
-- Allow built-in functions to overwrite extra functions.
for code, func in pairs(linkFunctions) do
local link = extraLinkFunctionfunc(snippets)
links[nextBuiltInKeycode] = link
end
return function (t, key)
return nextBuiltInKeynext(links, linkkey)
end
end