Module:Color

From Dota 2 Wiki
Jump to: navigation, search

Documentation for Module:Color Jump to code ↴ [ edit | purge ]

Reality Rift icon.png
▶️ Planeshift.
The documentation for this module can be found at Template:Color.
You may be forwarded to another wiki language, in case a translation is not available.


Dependencies

local p = {}
local colors = mw.loadData('Module:Color/data')
local getArgs = require('Module:Arguments').getArgs


function p.main(frame)
  local args = getArgs(frame, {
    wrappers = {
      'Template:Color'
    }
  })

  local success, result = pcall(p._main, args)
  if success then
    return mw.text.nowiki(result)
  else
    -- Returning an empty string to prevent old templates from breaking.
    -- TODO: Update all templates.
    return ''
  end
end

function p._main(args)
  assert(args[1], 'Missing input')
  return colors[args[1]:lower()] or args[1]
end


return p