Module:Infobox: रिवीजन सभ के बीचा में अंतर

Content deleted Content added
imported>Mr. Stradivarius on tour
use tostring() in getArgNums() - this is quicker than forcing concatenation of numbers
better comments
लाइन 11:
function union(t1, t2)
-- returnReturns the union of the values of two tables, as a sequence.
local vals = {}
for k, v in pairs(t1) do
लाइन 27:
 
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
Line 37 ⟶ 40:
 
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
Line 159 ⟶ 164:
 
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)
Line 206 ⟶ 213:
 
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')
Line 249 ⟶ 258:
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)
-- This function parsesParse the parameters with the given prefixes, in order, in batches of the step size specified.
-- 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)
Line 259 ⟶ 269:
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
"https://bh.wikipedia.org/wiki/Module:Infobox" से लिहल गइल