Module:String

From HorizonXI Wiki
Revision as of 08:04, 1 September 2025 by Kaimoon0 (talk | contribs) (join: non-empty arguments only)

Documentation for this module may be created at Module:String/doc

--[[

A module for general string functions.

]]

local str = {}

--[[
join

Using the first argument as a separator, join the remaining non-empty arguments
together.
Example:
{{#invoke:String|join|,|apples|bananas|cherries}}
]]

function str.join(frame)
    local separator = frame.args[1]
    local parts = {}

    for k, v in ipairs(frame.args) do
        if k > 1 and v ~= '' then
            table.insert(parts, v)
        end
    end

    return table.concat(parts, separator)
end

return str