Module:Sandbox/ChaoticShadow/InfoboxBuilder: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 241:
end
 
--- GetsDetermines if the non-nilrow should be shown contentbased fromof a list of param names
-- @param param_names { param_name, ... }
-- param_name string
-- The param name
-- @return actual_valuesshould_show { content, ... }boolean
function InfoboxBuilder:getNonNilContentshouldShow(param_names)
-- content string
if param_names and #param_names > 0 then
-- The processed content associated with a param
local actual_values = {}
function InfoboxBuilder:getNonNilContent(param_names)
for i,v in ipairs(param_names) do
local actual_values = {}
table.insert(actual_values, self:getContent(v))
for i,v in ipairs(param_names) do
end
table.insert(actual_values, self:getContent(v))
end
if #actual_values == 0 then
return selffalse
end
end
return actual_valuestrue
end
 
 
--- Adds a header
Line 269 ⟶ 274:
-- css {...} or nil
-- The css of the cell in table form
-- @param options { hideIfEmpty }
-- hideIfEmpty { param_name, ... }
-- contentparam_name string
-- The param_name that will be used to check if corresponding
-- The processed content associatedis with a paramnil
-- @return self
-- The current object
function InfoboxBuilder:addHeader(arg, options)
if options then
if local actual_values =not self:getNonNilContentshouldShow(options.hideIfEmpty) then
return self
end
end
self:addSpacer()
Line 306 ⟶ 322:
 
--- Adds an image, or switchable images
-- @param ...cols { { tag, content, title }, ... }
-- tag "artd" or "td"
-- Whether or not an it is based off a parameter
Line 313 ⟶ 329:
-- title string or nil
-- The title, if using switchable images
-- @param options { hideIfEmpty }
-- hideIfEmpty { param_name, ... }
-- param_name string
-- The param_name that will be used to check if corresponding
-- content is nil
-- @return self
-- The current object
function InfoboxBuilder:addImage(...cols, options)
if options then
local argt = ...
if not self:shouldShow(options.hideIfEmpty) then
return self
end
end
local _cell = self.infobox:tag('tr'):tag('td'):css('text-align', 'center')
Line 322 ⟶ 347:
local actual_args = {}
for _,v in ipairs(argtcols) do
local c = v.content
if v.tag == 'argtd' then
Line 380 ⟶ 405:
function InfoboxBuilder:addRow(cols, options)
if options then
if options.hideIfEmptynot and #self:shouldShow(options.hideIfEmpty > 0) then
return self
local actual_values = self:getNonNilContent(options.hideIfEmpty)
end
if #actual_values == 0 then
return self
end
end
end