Module:Ports resources
Jump to navigation
Jump to search
Module documentation
This documentation is transcluded from Module:Ports resources/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Ports resources/doc. [edit]
Module:Ports resources's function main is invoked by Template:Pop resource.
Module:Ports resources loads data from Module:Ports resources/data.
| Function list |
|---|
| L 10 — p.main |
--
-- Implements [[Template:Pop resource]]
--
local p = {}
local lang = mw.language.getContentLanguage()
local commas = function (n) return lang:formatNum(n) end
local resources = mw.loadData('Module:Ports resources/data')
function p.main(frame)
local args = frame:getParent().args
local amt = string.lower(args[1] or 'no')
local resource = resources[string.lower(args[2] or '')] or ''
local ret
if amt == 'no' or amt == '' then
ret = resource
else
amt = tonumber(amt:gsub(',',''),10)
ret = mw.html.create('span')
:css('white-space','nowrap')
:wikitext(commas(amt) .. ' ' .. resource)
end
return ret
end
return p