Module:Data/Templates

From Yugipedia
< Module:Data
Revision as of 15:42, 7 February 2019 by Becasita (talk | contribs) (Get vg info.)
Jump to: navigation, search
-- <pre>
--[=[Doc
@module Data/Templates
@description Interface for template interaction.
@author [[User:Becasita]]
@contact [[User talk:Becasita]]
]=]

local DATA = require( 'Module:Data' )

local D = {}

local function getLanguage( frame )
	local v = frame:getParent().args[ 1 ]

	return DATA.getLanguage( v ) or {}
end

local function getRegion( frame )
	local v = frame:getParent().args[ 1 ]

	return DATA.getRegion( v ) or {}
end

local function getMedium( frame )
	local v = frame:getParent().args[ 1 ]

	return DATA.getMedium( v ) or {}
end

local function getVideoGame( frame )
	local v = frame:getParent().args[ 1 ]

	return DATA.getVideoGame( v ) or {}
end

function D.ln( frame )
	return getLanguage( frame ).index or ''
end

function D.lang( frame )
	return getLanguage( frame ).full or ''
end

function D.rg( frame )
	return getRegion( frame ).index or ''
end

function D.region( frame )
	return getRegion( frame ).full or ''
end

function D.rgo( frame )
	return getMedium( frame ).abbr or ''
end

function D.vg( frame )
	local full = mw.text.trim( frame:getParent().args[ 'full' ] or '' ) ~= ''
	return getVideoGame( frame )[ full and 'full' or 'abbr' ] or ''
end

return D
-- </pre>