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
local countryMask = require "Module:Infobox road/meta/mask/country"
function p.color(frame)
local pframe = frame:getParent()
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 = args.state
state = emptyParam(state)
local province = args.province
province = emptyParam(province)
local type = args.type
local countryArg = args.country
countryArg = emptyParam(countryArg)
local stateParam = state or province
local countryLookup = countryMask._country(stateParam, countryArg)
if not(stateParam) then
return countryArg
elseif not(countryArg)
then return "default"
else return countryLookup
end
end