Module:Variations
Appearance
| This module is being discussed in accordance with Wikipedia's deletion policy. Help reach a consensus at its entry. |
| If you are going to move this module to another title, please move the corresponding template Template:Variations too. |
Usage
[edit]This is the module for Template:Variations where it is used like this: <includeonly>{{#invoke:Variations|main}}</includeonly>
local p = {}
function p.main(frame)
local args = frame:getParent().args
local output = {}
-- Start table
table.insert(output, '{| class="wikitable" style="margin: auto;"')
-- First entry is always "Plain" (now supports multiple symbols)
if args['1-symbol'] then
-- Collect all symbols for entry 1
local symbols = {args['1-symbol']}
-- Additional symbols (b, c, d, ...)
local letters = {'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}
for _, letter in ipairs(letters) do
if args['1-symbol-' .. letter] then
table.insert(symbols, args['1-symbol-' .. letter])
else
break
end
end
-- Output rows for entry 1
local numSymbols = #symbols
for j, symbol in ipairs(symbols) do
table.insert(output, '|-')
table.insert(output, '| style="font-size: 25px;" | ' .. frame:expandTemplate{title='IPA', args={symbol}})
-- Add "Plain" with rowspan on first symbol only
if j == 1 then
if numSymbols > 1 then
table.insert(output, '| rowspan="' .. numSymbols .. '" | Plain')
else
table.insert(output, '| Plain')
end
end
end
end
-- Process remaining numbered entries
local i = 2
while args[i .. '-symbol'] do
local description = args[i .. '-description'] or ''
-- Collect all symbols for this entry (symbol, symbol-b, symbol-c, etc.)
local symbols = {}
-- First symbol (no suffix)
if args[i .. '-symbol'] then
table.insert(symbols, args[i .. '-symbol'])
end
-- Additional symbols (b, c, d, ...)
local letters = {'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}
for _, letter in ipairs(letters) do
if args[i .. '-symbol-' .. letter] then
table.insert(symbols, args[i .. '-symbol-' .. letter])
else
break
end
end
-- Output rows
local numSymbols = #symbols
for j, symbol in ipairs(symbols) do
table.insert(output, '|-')
table.insert(output, '| style="font-size: 25px;" | ' .. frame:expandTemplate{title='IPA', args={symbol}})
-- Add description with rowspan on first symbol only
if j == 1 then
if numSymbols > 1 then
table.insert(output, '| rowspan="' .. numSymbols .. '" | ' .. description)
else
table.insert(output, '| ' .. description)
end
end
end
i = i + 1
end
-- Close table
table.insert(output, '|}')
return table.concat(output, '\n')
end
return p