Module:Navbox: Difference between revisions
apparently none of the test cases test tracking categories. fix a bunch of script errors
m>Jackmcbarn (don't use globals) |
m>Jackmcbarn (apparently none of the test cases test tracking categories. fix a bunch of script errors) |
||
Line 256: | Line 256: | ||
-- Tracking categories | -- Tracking categories | ||
-- | -- | ||
local function needsHorizontalLists() | local function needsHorizontalLists() | ||
Line 295: | Line 274: | ||
end | end | ||
local function getTrackingCategories() | |||
local cats = {} | |||
if needsHorizontalLists() then table.insert(cats, 'Navigational boxes without horizontal lists') end | |||
if hasBackgroundColors() then table.insert(cats, 'Navboxes using background colours') end | |||
return cats | |||
end | |||
local function renderTrackingCategories(builder) | |||
local frame = mw.getCurrentFrame() | |||
if not frame then return end | |||
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 | |||
for i, cat in ipairs(getTrackingCategories()) do | |||
builder.wikitext('[[Category:' .. cat .. ']]') | |||
end | |||
end | |||
-- | -- |