17,101
edits
(_Currency: Conditional formatting for negative amounts, and refactor to avoid repeated string concatenation) Tag: Reverted |
Tag: Undo |
||
Line 843: | Line 843: | ||
end | end | ||
function p._Currency(fileName, link, altText, | function p._Currency(fileName, link, altText, amt, maxAmt) | ||
local | local amtText = nil | ||
if tonumber(amt) ~= nil then | |||
amtText = formatnum(amt) | |||
if maxAmt ~= nil and maxAmt >= amt then | |||
amtText = amtText .. ' - ' .. formatnum(maxAmt) | |||
end | |||
end | |||
local fileText = '' | |||
if fileName ~= nil then | if fileName ~= nil then | ||
fileText = '[[File:' .. fileName .. '|25px' | |||
if link ~= nil then | if link ~= nil then | ||
fileText = fileText .. '|link=' .. link | |||
end | end | ||
fileText = fileText .. '|alt=' .. ((altText == nil and '') or altText) .. ']]' | |||
end | end | ||
return '<span style="display:inline-block">' .. fileText .. (amtText ~= nil and ' ' .. amtText or '') .. '</span>' | |||
end | end | ||