Цей модуль реалізує шаблон {{КШВ}}.
p = {}
p.criterion = function(f)
local args = f.args or f
if f == mw.getCurrentFrame() and args[1] == nil then
args = f:getParent().args
end
local criterionName = args[1]
assert(criterionName, "Критерій швидкого видалення не вказаний")
local criteria = mw.loadData("Модуль:КШВ/Критерії")
local criterion = criteria[criterionName]
assert(criterion, string.format("Критерій швидкого видалення «%s» не існує", criterionName))
if type(criterion) == "table" then
local variant = args[3]
if (not variant) or (variant == "") then
variant = "замовчування"
end
local variantText = criterion[variant]
assert(variantText, string.format("Варіанту для критерію швидкого вилучення не існує"))
criterion = variantText
end
local mode = args[2]
if (not mode) or (mode == "") then
mode = "номер+посилання"
end
if mode == "номер" then
return string.format("%s: %s", criterionName, criterion)
elseif mode == "номер+посилання" then
return string.format("[[MCW:КШВ#%s|%s]]: %s", criterionName, criterionName, criterion)
elseif mode == "безномеру" then
return criterion
else
error(string.format("Невідомий режим для критерію"))
end
end
return p