Module:Navbox: Difference between revisions

Jump to navigation Jump to search
41 bytes added ,  9 March 2013
correct fix for empty args
(bodystyle fix)
(correct fix for empty args)
Line 16: Line 16:
     return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))
     return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))
end
end
 
function addTableRow(tbl)
function addTableRow(tbl)
     -- If any other rows have already been added, then we add a 2px gutter row.
     -- If any other rows have already been added, then we add a 2px gutter row.
Line 264: Line 264:
--
--
function renderTrackingCategories(builder)
function renderTrackingCategories(builder)
    local frame = mw.getCurrentFrame()
   
     if not frame then return end
     if not frame then return end
      
      
Line 351: Line 353:
      
      
     for k, v in pairs(args) do
     for k, v in pairs(args) do
         if v == '' then
         local listnum = ('' .. k):match('^list(%d+)$')
            -- ParserFunctions considers the empty string to be false, so to preserve the previous
        if listnum then table.insert(listnums, tonumber(listnum)) end
            -- behavior of {{navbox}}, change any empty arguments to nil, so Lua will consider
            -- them false too.
            args[k] = nil
        else
            local listnum = ('' .. k):match('^list(%d+)$')
            if listnum then table.insert(listnums, tonumber(listnum)) end
        end
     end
     end
     table.sort(listnums)
     table.sort(listnums)
Line 400: Line 395:
end
end
   
   
function p.navbox(frm)
function p.navbox(frame)
     frame = frm
     -- ParserFunctions considers the empty string to be false, so to preserve the previous
     return p._navbox(frame:getParent().args)
    -- behavior of {{navbox}}, change any empty arguments to nil, so Lua will consider
    -- them false too.
    local args = {}
     for k, v in pairs(frame:getParent().args) do
        if v ~= '' then
            args[k] = v
        end
    end
    return p._navbox(args)
end
end
   
   
return p
return p
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu