Jump to content

Module:Infobox road/color/sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Fredddie (talk | contribs) at 06:59, 18 February 2021. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {} 

local format = mw.ustring.format
local lower = mw.ustring.lower
local getArgs = require('Module:Arguments').getArgs	
local parser = require("Module:Road data/parser").parser

function p.color(frame)
	local pframe = frame:getParent()
	local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
	local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template
	
	local function emptyParam(param)
		local empty = {[''] = true, ['¬'] = true}
		if not(param) or empty[param] then
			return nil
		else
			return param
		end
	end
	
	local state = config.state or args.state
	state = emptyParam(state)
	local province = config.province or args.province
	province = emptyParam(province)
	local type = config.type or args.type

	local countryArg = config.country or args.country
	countryArg = emptyParam(countryArg)
	local country = countryArg
	if not(country) then
		if colors[headerType] then
			country = ''
		else
			local stateParam = state or province
			if not(stateParam) then
				country = ''
			else
				local countryMask = require "Module:Infobox road/meta/mask/country"
				country = countryMask._country(stateParam, countryArg)
			end
		end
	end
	
	return country
end