Module:Sandbox/ChaoticShadow/InfoboxBuilder: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 117:
--- Sets both the text and background color of the header
-- @param
-- Parameter name that helps map the colors
-- @param color_table { text, bg }
-- text string
Line 126:
-- @return self
-- The current object
function InfoboxBuilder:setHeaderColorsByParam(
if
error("Parameter name must not be nil")
elseif color_table == nil then
Line 133:
end
local raw_param_value = self.raw_args[
local colors = color_table[raw_param_value]
Line 202:
--- Gets the content associated with a parameter
-- @param
-- The param name, not nil or empty
-- @return content string
-- A string containing the content
function InfoboxBuilder:getContent(
if
error("Param must not be nil or empty")
end
if self.proc_args[
return self.proc_args[
end
local content = nil
local current_param = self.params[
if current_param == nil then
error(string.format("No such param with name: %s",
end
local raw_param_value = self.raw_args[
if raw_param_value == nil then
Line 239:
return content
end
--- Gets the non-nil content from a list of param names
-- @param param_names { param_name, ... }
-- param_name string
-- The param name
-- @return actual_values { content, ... }
-- content string
-- The processed content associated with a param
function InfoboxBuilder:getNonNilContent(param_names)
local actual_values = {}
return actual_values
end
--- Adds a header
-- @param arg { content, attr, colspan, rowspan, css }
-- content string or nil
--
--
--
--
-- The colspan of the cell
-- roswpan number or nil
-- The rowspan of the cell
-- css {...} or nil
-- The css of the cell in table form
-- @return self
-- The current object
Line 286 ⟶ 307:
--- Adds an image, or switchable images
-- @param ... { { tag, content, title }, ... }
-- tag "artd" or "td"
--
--
-- The content or the parameter name
-- title string or nil
-- The title, if using switchable images
-- @return self
-- The current object
Line 332 ⟶ 356:
--- Adds a row, with columns up to 30 columns spanned
-- @param cols { { tag, content, hide, attr, colspan, rowspan, css }, ... }
-- tag "th", "td", "argth", "argtd"
--
-- content as the wikitext, "argth"
-- the parameter name to produce the
-- content string
--
-- attr {...} or
--
-- colspan number or nil
--
--
-- The rowspan of the cell
-- css {...} or nil
-- The css of the cell in table form
-- @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:addRow(
if options then
if options.hideIfEmpty and #options.hideIfEmpty > 0 then
local actual_values =
▲ for i,v in ipairs(options.hideIfEmpty) do
▲ table.insert(actual_values, self:getContent(v))
▲ end
if #actual_values == 0 then
|