Module:Infobox: Difference between revisions

Barebones functional infobox module, WIP
(WIP)
(Barebones functional infobox module, WIP)
Line 215:
self.switch_datatable:tag('span'):wikitext('Default version: '..self.default_version)
end
return self
end
 
Line 268 ⟶ 269:
end
-- Let's build the datatable
-- Prepend raw_raw__ or smw_smw$<__ if not a parsed argument
local name = content.param_name
if content.property == 'args_raw' then
name = 'raw_raw__' + name
end
if content.property == 'args_smw' then
name = 'smw_smw__' + name
end
data_param = self.switch_datatable:tag('span'):attr('data-attr-param', name)
Line 330 ⟶ 331:
end
 
local content = Infobox:get_param(v.content, self.default_version)
-- Make sure that all params are only called from Infobox.param(), and not raw_param() nor smw_param()
if type(v.content) == 'table' and v.content.property ~= 'args_parsed' then
table.insert(table.errors, 'Only Infobox.param() can be used in addRow, not Infobox.raw_param() nor Infobox.smw_param()! '..mw.dumpObject(args))
end
 
content = Infobox:get_param(v.content, self.default_version)
if content == nil then
content = edit
Line 342 ⟶ 338:
 
-- Add the switch data if multiple values exist
data_attr_param = self:add_switch_data(v.content)
if data_attr_param then
_cell:attr('data-attr-param', data_attr_param)
Line 358 ⟶ 354:
-- Override tostring
function Infobox:tostring()
-- If not finished, finish
if not self.__finished then
self:finish()
end
 
error_text = ''
if #self.errors > 0 then
Line 376 ⟶ 367:
function Infobox:dump()
mw.log(mw.dumpObject(self))
mw.log(tostring(self))
end