local p =
function p.Colour(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 roadclosed = args["uc_former"] or "" -- get special status (closed/uc) local roadtype = args["type"] or "" -- get road type roadclosed = string.lower(roadclosed) -- change roadclosed to lower case roadtype = string.lower(roadtype) -- change roadtype to lower case roadclosed = string.gsub(roadclosed, "%s+", "_") --remove spaces and replace with underscores for table access roadtype = string.gsub(roadtype, "%s+", "_") --remove spaces and replace with underscores for table access local colours = if not(roadtype) and not(roadclosed) then return "background-color: #e6c4fb;" -- if inputs missing, go purple elseif roadclosed and colours[roadclosed] then return colours[roadclosed] -- if road has a special type, and if it makes sense get return colour elseif roadtype and colours[roadtype] then return colours[roadtype] -- otherwise check the type makes sense, and get return colour else return "background-color: #e6c4fb;" -- all other cases go purple endendreturn p