Module:Sandbox/User:Microbrews/Variants: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 33:
function p.variants_header(args)
local smw_data = get_table_info(args)
local main_variant = args[1]:gsub('%(', '%%%('):gsub('%)', '%%%)') -- it's going to be a pattern, so escape the parentheses
local contents
if smw_data then
Line 40:
local name = entry['page']
local variant_name = name:gsub(main_variant, '', 1)
variant_name = variant_name:gsub('^%s*(.-)%s*$', '%1') -- trim whitespace
variant_name = variant_name:gsub('%((.-)%)$', '%1') -- trim parentheses
table.insert(formatted, '[[' .. name .. '|' .. variant_name .. ']]')
end
291

edits