Module:Navbar/sandbox: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
if a page does {{#invoke:navbar|navbar}}, figure out the title automatically
Jackmcbarn (talk | contribs)
use Module:Arguments to, among other things, support both direct args and parent args
Line 1:
local p = {}
 
local getArgs
local HtmlBuilder = require('Module:HtmlBuilder')
 
Line 134 ⟶ 135:
 
function p.navbar(frame)
if not getArgs then
local origArgs
getArgs = require('Module:Arguments').getArgs
-- If called via #invoke, use the args passed into the invoking template.
end
-- Otherwise, for testing purposes, assume args are being passed directly in.
return _navbar(argsgetArgs(frame))
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
else
origArgs = frame
end
-- ParserFunctions considers the empty string to be false, so to preserve the previous
-- behavior of {{navbar}}, change any empty arguments to nil, so Lua will consider
-- them false too.
local args = {}
for k, v in pairs(origArgs) do
if v ~= '' then
args[k] = v
end
end
return _navbar(args)
end