Модуль:SignedNumber
Для документации этого модуля может быть создана страница Модуль:SignedNumber/doc
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.main(frame)
local args = getArgs(frame, { removeBlanks = false })
local value = args[1]
if not value then
return ""
end
local invert = args.invert
local num = tonumber(value)
local color
if num then
if invert then
color = num > 0 and "bad" or "good"
else
color = num > 0 and "good" or "bad"
end
else
color = "text"
end
local amt = num and ((num > 0) and ("+" .. num) or tostring(num)) or tostring(value)
return frame:preprocess(string.format("{{цвет|text|%s|c='''%s'''}}", color, amt))
end
return p