Module:Variants: Difference between revisions

m
spaces to tabs
(Do not error when Variant name isn't defined)
m (spaces to tabs)
Line 12:
local variant_name = args.variant or mw.title.getCurrentTitle().fullText
local query = {
'[[Variant of::'..variant_name..']]',
'?Profession A #', -- Adding a # to this query makes it return plaintext instead of a link
'?Profession B #',
'?Profession Level A',
'?Profession Level B',
'?Profession Level A High',
'?Profession Level B High',
'?Variant name',
get_images and '?Image#64px;x64px = Image' or nil,
limit = args.limit or 500,
}
}
local smw_data = mw.smw.ask(query)
if not smw_data then
Line 35:
local contents
if smw_data then
local formatted = {}
for _, entry in ipairs(smw_data) do
if entry['Variant name'] then
local page = entry[1]
local pipe = page:find('|')
if pipe then
page = page:sub(3, pipe-1)
else
page = page:sub(3, -3)
end
table.insert(formatted, ('[[%s|%s]]'):format(page, entry['Variant name']))
else
table.insert(formatted, entry[1])
end
end
end
contents = table.concat(formatted, ' • ')
else
703

edits