Module:LegendRJL

local p = { } -- Package to be exported p.mw = require( "Module:Mw" )

local columns = {  --Constants for how many columns different list types should have. default = 6,   --default exit = 7,      --default + exit number old = 8,       --default + exit number + old exit number }

local legendtext = { --Constants for the actual text of the legend standard = [=[ ]=], --Standard legend only UK = [=[ ]=] --UK legend only }
 * Concurrency terminus
 * Closed/former
 * HOV only
 * Incomplete access
 * Tolled/ETC
 * Unopened
 * Motorway
 * Primary road
 * Secondary road

function colspan(listType) --This function determines the proper number of columns and outputs a colspan cell of the appropriate size. local columnNumber = columns[listType] or columns.default return string.format('|colspan = %s class="wikitable hlist" style="text-align: center; background-color:#f2f2f2;"|', columnNumber) end

function p.colspan(frame) --This function calls the function that determines the proper number of columns and outputs a colspan cell of the appropriate size. 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 --If the "col" parameter is specified by the template user, that overrides anything else. --Otherwise, call the colspan function to determine the correct number of columns. local col = args['col'] if col and col ~= '' then return string.format('|colspan = %s class="wikitable hlist" style="text-align: center; background-color:#f2f2f2;"|', col) else local listType = args[1] --get argument that explains what type of list this is       return colspan(listType) end end

function p.legend(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 listcountry = args['country'] --get argument to discover if this is a UK article or not local outputstring --variable to hold what will be output by the template --If this is a UK article, output both legends. If not, just output the standard one. if listcountry == 'UK' or listcountry == 'GBR' then outputstring = legendtext.UK .. legendtext.standard else outputstring = legendtext.standard end return(outputstring) end

return p