Module:Color

From Inkipedia, the Splatoon wiki

Summary

Colors text the specified color.

{{Color|<The Text>|<The Color>|<ingame>}}

If ingame is present, the named color is passed to {{TextColor|<color>}} to show in-game color, instead of using HTML notation

To color links, see {{Color-link}}

Examples

Code Result
{{color|Named Example|red}} Named Example
{{color|In-Game Example|Orange S2|ingame}} In-Game Example
{{color|Hex Example|#0055FF}} Hex Example

local p = {}
local textColor = require('Module:TextColor')

-- Function to handle the color text
function p.main(frame)
    local args = frame:getParent().args
    local text = args[1] or ""
    local color = args[2] or ""
    local ingame = args[3] or ""

    -- Check if the color is supposed to be an in-game color
    if ingame == "ingame" then
        color = 'rgb('.. textColor.getColor(color) ..')'
    end

    return '<span style="color:' .. color .. '">' .. text .. '</span>'
end

return p