Module:Navbox/sandbox: Difference between revisions

Content deleted Content added
sync
improve ease of access from other Lua modules, expand the comments a little
Line 381:
function p.navbox(frame)
-- If called via #invoke, use the args passed into the invoking template. Otherwise,
-- ParserFunctions considers the empty string to be false, so to preserve the previous
-- assume args are being passed directly in from the debug console or from another Lua module.
-- behavior of {{navbox}}, change any empty arguments to nil, so Lua will consider
local args = {}origArgs
-- them false too.
if frame == mw.getCurrentFrame() then
local args = {}
local parent_args origArgs = frame:getParent().args;
else
origArgs = frame;
end
 
-- OutFix offor the out-of-order parsing bug. The arguments need to be processed in the same order
-- that they were processed in the old {{navbox}} template. If they are processed in a different
-- order, we see errors such as {{reflist}} templates being processed before the references that
-- are supposed to appear in them.
local temp;
temp = parent_argsorigArgs.title;
temp = parent_argsorigArgs.above;
for i = 1, 20 do
temp = parent_argsorigArgs["group" .. tostring(i)];
temp = parent_argsorigArgs["list" .. tostring(i)];
end
temp = parent_argsorigArgs.below;
 
-- ParserFunctions considers the empty string to be false, so to preserve the previous
for k, v in pairs(parent_args) do
-- behavior of {{navbox}}, change any empty arguments to nil, so Lua will consider
if v ~= '' then
-- them false too.
local args = {}
for k, v in pairs(parent_argsorigArgs) do
if mw.ustring.find(v ~=, '%S') then
args[k] = v
end