Zum Inhalt springen

Modul:Navbox: Unterschied zwischen den Versionen

various fixes from sandbox
(don't require the wrapper template)
(various fixes from sandbox)
Zeile 7: Zeile 7:
local HtmlBuilder = require('Module:HtmlBuilder')
local HtmlBuilder = require('Module:HtmlBuilder')
local navbar = require('Module:Navbar')._navbar
local navbar = require('Module:Navbar')._navbar
local getArgs -- lazily initialized


local args
local args
local frame
local tableRowAdded = false
local tableRowAdded = false
local border
local border
Zeile 282: Zeile 282:


local function renderTrackingCategories(builder)
local function renderTrackingCategories(builder)
     local frame = mw.getCurrentFrame()
     local title = mw.title.getCurrentTitle()
   
     if title.namespace ~= 10 then return end -- not in template space
     if not frame then return end
     local subpage = title.subpageText
   
    local s = frame:preprocess('{{#ifeq:{{NAMESPACE}}|{{ns:10}}|1|0}}{{SUBPAGENAME}}')
    if mw.ustring.sub(s, 1, 1) == '0' then return end -- not in template space
     local subpage = mw.ustring.lower(mw.ustring.sub(s, 2))
     if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end
     if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end
      
      
Zeile 382: Zeile 378:
   
   
function p.navbox(frame)
function p.navbox(frame)
     -- ParserFunctions considers the empty string to be false, so to preserve the previous
     if not getArgs then
    -- behavior of {{navbox}}, change any empty arguments to nil, so Lua will consider
    getArgs = require('Module:Arguments').getArgs
    -- them false too.
    end
    local args = {}
     args = getArgs(frame, {wrappers = 'Template:Navbox'})
    local parentTitle = frame:getParent():getTitle()
     local frame_args = (parentTitle == 'Template:Navbox' or parentTitle == 'Template:Navbox/sandbox') and frame:getParent().args or frame.args;


     -- Out of order parsing bug.
     -- Read the arguments in the order they'll be output in, to make references number in the right order.
     local temp;
     local _
     temp = frame_args.title;
     _ = args.title
     temp = frame_args.above;
     _ = args.above
     for i = 1, 20 do
     for i = 1, 20 do
         temp = frame_args["group" .. tostring(i)];
         _ = args["group" .. tostring(i)]
         temp = frame_args["list" .. tostring(i)];
         _ = args["list" .. tostring(i)]
     end     
     end     
     temp = frame_args.below;
     _ = args.below
   
 
    for k, v in pairs(frame_args) do
        if v ~= '' then
            args[k] = v
        end
    end
     return p._navbox(args)
     return p._navbox(args)
end
end
   
   
return p
return p
Anonymer Benutzer