Navigation menu

Module:Infobox: Difference between revisions

From The Kodiak Republic Wiki

fix for {{infobox}} with no input args generating an empty <table class="infobox"></table> per talk page
(add using-infobox tstyles support)
(fix for {{infobox}} with no input args generating an empty <table class="infobox"></table> per talk page)
Line 5:
local empty_row_categories = {}
local category_in_empty_row_pattern = '%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]'
local has_rows = false
 
local function fixChildBoxes(sval, tt)
Line 56 ⟶ 57:
else
return sval
end
end
 
-- Cleans empty tables
local function cleanInfobox()
root = tostring(root)
if has_rows == false then
root = mw.ustring.gsub(root, '<table[^<>]*>%s*</table>', '')
end
end
Line 94 ⟶ 103:
if rowArgs.header and rowArgs.header ~= '_BLANK_' then
has_rows = true
root
:tag('tr')
Line 115 ⟶ 125:
category_in_empty_row_pattern, ''
):match('^%S') then
has_rows = true
local row = root:tag('tr')
row:addClass(rowArgs.rowclass)
Line 147 ⟶ 158:
if not args.title then return end
 
has_rows = true
root
:tag('caption')
Line 159 ⟶ 171:
if not args.above then return end
 
has_rows = true
root
:tag('tr')
Line 173 ⟶ 186:
if not args.below then return end
 
has_rows = true
root
:tag('tr')
Line 187 ⟶ 201:
if subheaderArgs.data and
subheaderArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
local row = root:tag('tr')
row:addClass(subheaderArgs.rowclass)
Line 227 ⟶ 242:
if imageArgs.data and
imageArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
 
has_rows = true
local row = root:tag('tr')
row:addClass(imageArgs.rowclass)
Line 324 ⟶ 340:
if not args.name then return end
 
has_rows = true
root
:tag('tr')
Line 441 ⟶ 458:
renderEmptyRowCategories()
renderTrackingCategories()
cleanInfobox()
 
return loadTemplateStyles() .. tostring(root)
end
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.