Module:Money
Appearance
This documentation is transcluded from Module:Money/doc.
Output a money text using Module:IconText.
Implements Template:Money.
require( 'strict' )
local iconText = require( 'Module:IconText' )
local p = {}
--- Render the money text
---
--- @param moneyNum number
--- @return string
local function renderMoney( moneyNum )
local lang = mw.language.getContentLanguage()
return iconText._main( {
icon = 'General money icon.png',
text = lang:formatNum( moneyNum ),
class = 't-money cp-image-pixelated'
} )
end
--- Wikitext entry point for the module
---
--- @param frame mw.frame
--- @return string
function p.main( frame )
local getArgs = require( 'Module:Arguments' ).getArgs
return p._main( getArgs( frame )[1] )
end
--- Render the money text
---
--- @param money string|number
--- @return string
function p._main( money )
local moneyNum = tonumber( money )
if not moneyNum then
error( 'Invalid money value: ' .. money )
end
return mw.getCurrentFrame():extensionTag {
name = 'templatestyles', args = { src = 'Module:Money/styles.css' }
} .. renderMoney( moneyNum )
end
return p