local Type = {}
local data = mw.loadData( 'Module:Type/data' )
local layoutdata = mw.loadData( 'Module:Layout/data' )
local function isempty(s)
-- Empty parameter check
  return s == nil or s == ''
function Type.type( frame )
-- Implements {{Type}}
-- This block calls the function _type, where the real magic happens.
-- This part just determines if it's from an #invoke or a Template; it makes sure the arguments are filled accordingly.
	if not isempty( frame.args[1] ) then
	  return Type._type( frame.args )
	  return Type._type( frame:getParent().args )
function Type.chartkey( frame )
-- Implements {{Type chart key}}
function Type._type( args )
-- The reusable part of Type, so that it can be called as a function from other Modules.
-- This first line throws an error when there's no first argument.
	assert( args[1], "There is no type listed.")
	local pokemontype = args[1]
	local fallbacktext = '[['..pokemontype..' type|<span style="color: #F8F8F8;">'..pokemontype..'</span>]]'
	local element = mw.html.create('span')
	  :css('border-style','solid none'):css('border-width','1px')
	  :css('font-size','9pt'):css('color','#F8F8F8'):css('text-shadow','0px 1px 1px #807870')
	  :wikitext( args[2] or fallbacktext ):allDone()
	return tostring(element)
function Type.color( frame )
-- Implements {{Normal}}, etc. (the "Color templates").
-- This really should just call data.color["Normal"] in other templates, and it will be much faster.
-- The template code would be:
-- <includeonly>{{invoke:Type|color|Normal}}</includeonly>
-- <noinclude>{{invoke:Type|color|Normal|description}}[[Category:Color templates]]</noinclude>
-- This first line throws an error when there's no first argument.
	assert( frame.args[1], "There is no type listed.")
	local pokemontype = frame.args[1]
	if not ( frame.args[2] == "description" ) then
	  return string.sub(data.color[string.lower(pokemontype)], 2)
	  local T = mw.html.create('table'):tag('tr')
	    :wikitext('[['..pokemontype..' Pokémon|<span style="color:#FFFFFF">'..pokemontype..'</span>]] color:'):done()
	    :wikitext( string.sub(data.color[string.lower(pokemontype)], 2) )
	  return tostring(T)
return Type