Module:Navbox/sandbox: Difference between revisions

Content deleted Content added
improve ease of access from other Lua modules, expand the comments a little
sync again - this won't be necessary after all
Line 381:
function p.navbox(frame)
-- ParserFunctions considers the empty string to be false, so to preserve the previous
-- If called via #invoke, use the args passed into the invoking template. Otherwise,
-- behavior of {{navbox}}, change any empty arguments to nil, so Lua will consider
-- assume args are being passed directly in from the debug console or from another Lua module.
-- them false too.
local origArgsargs = {}
if frame == mw.getCurrentFrame() then
local origArgsparent_args = frame:getParent().args;
else
origArgs = frame;
end
 
-- FixOut forof 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 = origArgsparent_args.title;
temp =origArgs parent_args.above;
for i = 1, 20 do
temp = origArgsparent_args["group" .. tostring(i)];
temp = origArgsparent_args["list" .. tostring(i)];
end
temp = origArgsparent_args.below;
else
 
for k, v in pairs(origArgsparent_args) do
-- ParserFunctions considers the empty string to be false, so to preserve the previous
if mw.ustring.find(v, ~= '%S') then
-- behavior of {{navbox}}, change any empty arguments to nil, so Lua will consider
-- them false too.
local args = {}
for k, v in pairs(origArgs) do
if mw.ustring.find(v, '%S') then
args[k] = v
end