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 insert = table.insert
local concat = table.concat
local lower = mw.ustring.lower
local getArgs = require('Module:Arguments').getArgs
local parserModule = require "Module:Road data/parser"
local parser = parserModule.parser
local function location(args)
local state = args.state or args.province or ''
args.state = state
local country
if args.country and args.country ~= '' then
country = upper(args.country)
else
local countryModule = mw.loadData("Module:Road data/countrymask")
country = countryModule[state] or 'UNK'
end
args.country = country
end
local uc = "under construction" or "const" or "uc"
local hist = "hist" or "historic" or "historical"
local deleted = "decommissioned" or "deleted" or "former"
function p.header(args, frame)
local color = parser(args, 'color')
local headerType = lower(args.header_type) or uc
if color == '' or color == nil then
return tostring("background:#cedff2;")
elseif headerType == uc then
return tostring("background:#fc6;")
elseif headerType == hist then
return tostring("background:#704214; color:#fff;")
elseif headerType == deleted then
return tostring("background:#AAA;")
else return color
end
end
function p.border(args, frame)
local border = parser(args, 'border')
if border == '' or border == nil then
return tostring("#cedff2;")
else return border
end
end
return p