Module:Infobox road/color/sandbox
Appearance
![]() | This is the module sandbox page for Module:Infobox road/color (diff). See also the companion subpage for test cases (run). |
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 = 'UNK'
else
local countryMask = require "Module:Infobox road/meta/mask/country"
country = countryMask._country(stateParam, countryArg)
end
end
end
return country
end