Changes

Jump to navigation Jump to search

Module:Infobox

672 bytes added, 11:30, 4 June 2013
better comments
function union(t1, t2)
-- return Returns the union of the values of two tables, as a sequence.
local vals = {}
for k, v in pairs(t1) do
local function getArgNums(prefix)
-- Returns a table containing the numbers of the arguments that exist
-- for the specified prefix. For example, if the prefix was 'data', and
-- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
local nums = {}
for k, v in pairs(args) do
local function addRow(rowArgs)
-- Adds a row to the infobox, with either a header cell
-- or a label/data cell combination.
if rowArgs.header then
root
local function renderRows()
-- Gets the union of the header and data argument numbers,
-- and renders them all in order using addRow.
local rownums = union(getArgNums('header'), getArgNums('data'))
table.sort(rownums)
local function _infobox()
-- Specify the overall layout of the infobox, with special settings
-- if the infobox is used as a 'child' inside another infobox.
if args.child ~= 'yes' then
root = HtmlBuilder.create('table')
end
-- This function parses the parameters with the given prefixes, in order, in batches of the step size specified.
-- If the step size is not given, the default is 20.
local function touchParameters(prefixTable, origArgs, step)
-- Parse the parameters with the given prefixes, in order, in batches
-- of the step size specified. This is to prevent references etc. from
-- appearing in the wrong order.
if type(prefixTable) ~= 'table' or type(origArgs) ~= 'table' then
error("Invalid input to the touchParameters function detected. Both parameters must be tables.", 2)
end
step = step or 20-- If the step size is not given, the default is 20.
local temp
local a = 1-- Counter variable.
local moreArgumentsExist = true
for j,v in ipairs(prefixTable) do
Anonymous user

Navigation menu