Module:Capitalize

From ARMS Institute, the ARMS Wiki
Jump to navigation Jump to search

This module is used to return the inserted "words" variable in 'Title Case' format. All words within the string will be capitalized accordingly.

Usage

Insert string gotten from arguments on templates as "words" variable. Useful for calling on .png titles that share the 'Title Case' format.

local properImageName = require( 'Module:Capitalize' ).main
local p = {}

function p.main( args )
    --Returns Title Case formatted string
    args[1] = properImageName(args[1])
end

return p

local p ={}

function p.main(words)
    if words then
        words = words:gsub("(%a)(%a+)", function(a, b) return string.upper(a) .. string.lower(b) end)
        return words
    end
end

return p