Module:TrimArray: Difference between revisions
Appearance
Created page with "local p = {} -- Function to convert a comma-separated list into clean formredlinks function p.mineralLinks(frame) local input = frame.args[1] or "" local out = {} for item in mw.text.gsplit(input, ",", true) do local trimmed = mw.text.trim(item) if trimmed ~= "" then table.insert(out, string.format( '{{#formredlink:form=Mineral|target=%s}}<br>', trimmed )) end end return table.concat(o..." |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.links(frame) | |||
function p. | |||
local input = frame.args[1] or "" | local input = frame.args[1] or "" | ||
local form = frame.args.form | |||
local out = {} | local out = {} | ||
| Line 10: | Line 10: | ||
if trimmed ~= "" then | if trimmed ~= "" then | ||
table.insert(out, string.format( | table.insert(out, string.format( | ||
'{{#formredlink:form= | '{{#formredlink:form=%s|target=%s}}<br>', form, trimmed | ||
)) | )) | ||
end | end | ||
end | end | ||
return table.concat(out) | return table.concat(out </br>) | ||
end | end | ||
return p | return p | ||
Latest revision as of 20:38, 28 October 2025
local p = {}
function p.links(frame)
local input = frame.args[1] or ""
local form = frame.args.form
local out = {}
for item in mw.text.gsplit(input, ",", true) do
local trimmed = mw.text.trim(item)
if trimmed ~= "" then
table.insert(out, string.format(
'%s
', form, trimmed
))
end
end
return table.concat(out
)
end
return p