Модуль:Ссылки
Внешний вид
Для документации этого модуля может быть создана страница Модуль:Ссылки/doc
-- Разбивает список через запятую и делает из каждого элемента ссылку.
-- {{#invoke:Ссылки|список|Иван Петров, Пётр Иванов}}
-- {{#invoke:Ссылки|список|конкур, выездка|ссылки=нет}}
local p = {}
local function trim(s)
return (s:gsub('^%s+', ''):gsub('%s+$', ''))
end
function p.list(frame)
local args = frame.args
local text = args[1] or ''
local nolinks = (args['ссылки'] == 'нет')
local sep = args['разделитель'] or ', '
local out = {}
for item in mw.text.gsplit(text, ',', true) do
item = trim(item)
if item ~= '' then
if nolinks then
table.insert(out, item)
else
table.insert(out, '[[' .. item .. ']]')
end
end
end
return table.concat(out, sep)
end
p['список'] = p.list
return p