Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:AeroWikiListTools: Difference between revisions

From Aeronautica Official Wiki
Sqwishyish (talk | contribs)
m added whitespaces between commas
Sqwishyish (talk | contribs)
mw.log(p.split_list({"TheOnly0Ne, Giovanni_085931, Enclaved_YT, EAT_RIC3", '[[Category: {split}]][[:Category: {split}|{split}]]'}))
Line 16: Line 16:
     local new_string = ''
     local new_string = ''
      
      
     if type(input_string) == table then
     if input_string == nil or template == nil then
input_string = table.concat(input_string, '')
return 'Unknown'
     end
     end



Revision as of 08:11, 29 April 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 new_string = ''
    
    if input_string == nil or template == nil then
		return 'Unknown'
    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
Cookies help us deliver our services. By using our services, you agree to our use of cookies.