Module:AeroWikiListTools: Difference between revisions
From Aeronautica Official Wiki
More actions
Sqwishyish (talk | contribs) Undo revision 548 by Sqwishyish (talk) Tag: Undo |
Sqwishyish (talk | contribs) m updated missing value to be changable |
||
Line 14: | Line 14: | ||
local input_string = args[1] | local input_string = args[1] | ||
local template = args[2] | local template = args[2] | ||
local missing_string = args[3] | |||
local new_string = '' | local new_string = '' | ||
if input_string == nil or template == nil then | if input_string == nil or template == nil then | ||
return | return missing_string | ||
end | end | ||
Revision as of 10:20, 1 May 2025
Documentation for this module may be created at Module:AeroWikiListTools/doc
local getArgs = require('Module:Arguments').getArgs
local p = {}
local function makeInvokeFunc(funcName)
return function (frame)
local args = getArgs(frame)
return p[funcName](args)
end
end
p.split_list = makeInvokeFunc('_split_list')
p._split_list = function (args)
local input_string = args[1]
local template = args[2]
local missing_string = args[3]
local new_string = ''
if input_string == nil or template == nil then
return missing_string
end
for split in string.gmatch(input_string , '([^,]+)') do
new_string = new_string .. template:gsub('{split}', split:match('^%s*(.-)%s*$')) .. ' '
end
if template:sub(-1) == ',' then
new_string = new_string:sub(1, -3)
elseif template:sub(-2) == ', ' then
new_string = new_string:sub(1, -4)
end
return new_string
end
return p