Module:TemplateHelpers: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 93: | Line 93: | ||
-- Process all keys | -- Process all keys | ||
for key, value in pairs(args) do | for key, value in pairs(args) do | ||
-- Determine if this key is numeric (number type or numeric-string) | |||
local isNumericKey = type(key) == "number" or (type(key) == "string" and tonumber(key) ~= nil) | |||
-- Skip empty numeric parameters (created by leading pipes after template name) | -- Skip empty numeric parameters (created by leading pipes after template name) | ||
if | if isNumericKey and (value == nil or value == "") then | ||
-- | -- do not copy empty positional arguments | ||
else | else | ||
-- For | -- For non-numeric string keys, add lowercase version | ||
if type(key) == "string" then | if type(key) == "string" and not isNumericKey then | ||
normalized[key:lower()] = value | normalized[key:lower()] = value | ||
end | end | ||