Module:Areas
From IdleOn MMO Wiki
Ref: Template:Areas
local p = {}
-- Module function to process the input and apply template
function p.process(frame)
-- Get the input argument
local input = frame.args[1]
-- Check if input is not nil or empty
if not input or input == '' then
return ''
end
-- Split the input string by commas, with possible spaces around them
local items = mw.text.split(input, "%s*,%s*")
-- Table to hold processed items
local processedItems = {}
-- Apply template to each item, and trim each item before applying the template
for _, item in ipairs(items) do
local trimmedItem = mw.text.trim(item)
local processedItem = frame:expandTemplate{ title = 'Area', args = { trimmedItem } }
table.insert(processedItems, processedItem)
end
-- Join the processed items with a comma and return
return table.concat(processedItems, ', ')
end
return p