Module:Variants: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(Only show the variant name and do not repeat the variant category name)
(Do not error when Variant name isn't defined)
Line 37: Line 37:
local formatted = {}
local formatted = {}
for _, entry in ipairs(smw_data) do
for _, entry in ipairs(smw_data) do
local page = entry[1]
if entry['Variant name'] then
local pipe = page:find('|')
local page = entry[1]
if pipe then
local pipe = page:find('|')
page = page:sub(3, pipe-1)
if pipe then
page = page:sub(3, pipe-1)
else
else
page = page:sub(3, -3)
page = page:sub(3, -3)
end
end
table.insert(formatted, ('[[%s|%s]]'):format(page, entry['Variant name']))
table.insert(formatted, ('[[%s|%s]]'):format(page, entry['Variant name']))
else
table.insert(formatted, entry[1])
end
end
end
contents = table.concat(formatted, ' • ')
contents = table.concat(formatted, ' • ')