Module:Infobox: Difference between revisions

m
65 revisions imported: Importing Template:Tmbox, with templates.
(fixed)
m (65 revisions imported: Importing Template:Tmbox, with templates.)
 
(6 intermediate revisions by 2 users not shown)
Line 8:
 
local args = {}
local origArgs = {}
local root
 
Line 113:
end
elseif rowArgs.data then
dvalif not rowArgs.data:gsub('%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]', ''):match('^%S') then
row_stylerowArgs.rowstyle = 'display:none'
end
local row = root:tag('tr')
row:addClass(rowArgs.rowclass)
Line 231 ⟶ 234:
local rownums = union(getArgNums('header'), getArgNums('data'))
table.sort(rownums)
local row_style
for k, num in ipairs(rownums) do
local dval = args['data' .. tostring(num)]
row_style = args['rowstyle' .. tostring(num)]
if args['header' .. tostring(num)] then
row_style = args['rowstyle' .. tostring(num)]
elseif dval and
dval:gsub('%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]', ''):match('%S')
then
row_style = args['rowstyle' .. tostring(num)]
else
row_style = 'display:none'
end
addRow({
header = args['header' .. tostring(num)],
Line 251 ⟶ 242:
class = args['class' .. tostring(num)],
rowclass = args['rowclass' .. tostring(num)],
rowstyle = row_styleargs['rowstyle' .. tostring(num)],
rowcellstyle = args['rowcellstyle' .. tostring(num)],
dataid = args['dataid' .. tostring(num)],
Line 408 ⟶ 399:
end
 
local function p.infoboxparseDataParameters(frame)
-- If called via #invoke, use the args passed into the invoking template.
-- Otherwise, for testing purposes, assume args are being passed directly in.
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
else
origArgs = frame
end
 
-- Parse the data parameters in the same order that the old {{infobox}} did, so that
-- references etc. will display in the expected places. Parameters that depend on
-- another parameter are only processed if that parameter is present, to avoid
-- phantom references appearing in article reference lists.
preprocessSingleArg('autoheaders')
preprocessSingleArg('child')
preprocessSingleArg('bodyclass')
Line 464 ⟶ 448:
args['italic title'] = origArgs['italic title'] -- different behaviour if blank or absent
preprocessSingleArg('decat')
end
 
function p.infobox(frame)
-- If called via #invoke, use the args passed into the invoking template.
-- Otherwise, for testing purposes, assume args are being passed directly in.
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
else
origArgs = frame
end
parseDataParameters()
return _infobox()
end
 
function p.infoboxTemplate(frame)
-- For calling via #invoke within a template
origArgs = {}
for k,v in pairs(frame.args) do origArgs[k] = mw.text.trim(v) end
parseDataParameters()
return _infobox()
end