Module:Sandbox/ChaoticShadow/InfoboxBuilder: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 333: | Line 333: | ||
--- Adds a row, with columns up to 30 columns spanned |
--- Adds a row, with columns up to 30 columns spanned |
||
-- @param should_hide boolean |
|||
⚫ | |||
-- The row will be hidden if all varying columns are nil |
|||
⚫ | |||
-- tag "th", "td", "argth", "argtd" |
-- tag "th", "td", "argth", "argtd" |
||
-- A string containing one of the above, "th" or |
-- A string containing one of the above, "th" or |
||
Line 347: | Line 349: | ||
-- @return self |
-- @return self |
||
-- The current object |
-- The current object |
||
function InfoboxBuilder:addRow(should_hide, |
function InfoboxBuilder:addRow(should_hide, cols) |
||
local argt = ... |
|||
local actual_values = {} |
local actual_values = {} |
||
for i,v in ipairs( |
for i,v in ipairs(cols) do |
||
if v.tag == 'argth' or v.tag == 'argtd' then |
if v.tag == 'argth' or v.tag == 'argtd' then |
||
table.insert(actual_values, self:getContent(v.content)) |
table.insert(actual_values, self:getContent(v.content)) |
||
Line 358: | Line 358: | ||
end |
end |
||
⚫ | |||
return mw.dumpObject(argt) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
local _row = self.infobox:tag('tr') |
|||
for i,v in ipairs(cols) do |
|||
local _cell = _row:tag(tagmap[v.tag] or 'td') |
|||
:attr('colspan', 30 / #cols) |
|||
if v.attr then |
|||
_cell:attr(v.attr) |
|||
end |
|||
if v.colspan then |
|||
_cell:attr('colspan', v.colspan) |
|||
end |
|||
if v.rowspan then |
|||
_cell:attr('rowspan', v.rowspan) |
|||
end |
|||
if v.css then |
|||
_cell:css(v.css) |
|||
end |
|||
if v.tag == 'th' or v.tag == 'td' then |
|||
_cell:wikitext(v.content) |
|||
elseif v.tag == 'argth' or v.tag == 'argtd' then |
|||
_cell:wikitext(self:getContent(v.content)) |
|||
end |
|||
end |
|||
return self |
|||
end |
end |
||