Module:Infobox: Difference between revisions

Ganaram inukshuk (talk | contribs)
m todo
Ganaram inukshuk (talk | contribs)
adopt template input utils function
Line 235: Line 235:
-- These functions are kept in the meantime to support older infoboxes and WILL
-- These functions are kept in the meantime to support older infoboxes and WILL
-- be entirely deleted later! Please switch to the new functions!
-- be entirely deleted later! Please switch to the new functions!
-- Helper function; preprocess infobox rows from old format to new format
-- One-element entries are interpreted as dataless headers, as it already is.
function p.preprocess_entries(entries)
local processed = {}
for i = 1, #entries do
local entry = entries[i]
if #entry == 1 then
table.insert(processed, { ["Header"] = entry[1] })
elseif #entry == 2 then
table.insert(processed, { ["Header"] = entry[1], ["Data"] = entry[2] })
end
end
return processed
end


-- Original function signature, kept for legacy support (for now).
-- Original function signature, kept for legacy support (for now).
Line 257: Line 241:
["Adjacent Links"] = { (prev_link or ""), (next_link or "") },
["Adjacent Links"] = { (prev_link or ""), (next_link or "") },
["Title"] = title,
["Title"] = title,
["Rows"] = p.preprocess_entries(entries),
["Rows"] = tiu.jagged_array_to_header_data_rows(entries)
}
}


Line 268: Line 252:
["Adjacent Links"] = adjacent_links,
["Adjacent Links"] = adjacent_links,
["Title"] = title,
["Title"] = title,
["Rows"] = p.preprocess_entries(entries),
["Rows"] = tiu.jagged_array_to_header_data_rows(entries)
}
}