-- Sandbox, do not delete
require('strict')
local p = {}
local getArgs = require('Module:Arguments').getArgs
local parserModule = require('Module:Road data/parser')
local parser = parserModule.parser
local types = {
TCH = '[[File:TCH-blank.svg|15px]] [[Trans-Canada Highway]]',
Yellowhead = '[[File:Yellowhead Blank.svg|15px]] [[Yellowhead Highway]]',
['2'] = 'Interprovincial Highway 2'
}
local function showRoute(route, routeType, routeLoc, currProvince)
local out = ''
local parserArgs = {
route = route,
type = routeType,
province = routeLoc
}
local shield = parser(parserArgs, 'shieldmain') or parser(parserArgs, 'shield') or ''
local label = parser(parserArgs, 'name') or parser(parserArgs, 'abbr') or ''
label = (routeLoc ~= currProvince and (routeLoc .. ' ') or '') .. label
local link = parser(parserArgs, 'link')
local alt = label .. ' marker'
if type(shield) == 'table' then
shield = shield[1]
end
out = out .. string.format('[[File:%s|15px|alt=%s]]', shield, alt)
if not link or link == '' then
out = out .. ' ' .. label
else
out = out .. ' ' .. string.format('[[%s|%s]]', link, label)
end
return out
end
local function edgeColumn(prefix, currProvince, args)
local index = 1
local out = ''
repeat
local route = args[prefix .. index] or (index == 1 and args[prefix] or '')
local routeType = args[prefix .. '_type' .. index] or (index == 1 and args[prefix .. '_type'] or '')
local routeLoc = args[prefix .. '_province' .. index] or (index == 1 and args[prefix .. '_province'] or '')
if index ~= 1 then
out = out .. '<hr>'
end
out = out .. showRoute(route, routeType, routeLoc, currProvince)
index = index + 1
until not args[prefix .. index]
return out
end
function p.main(frame)
local args = getArgs(frame)
local type = args.type
local route = args.curr
local routeType = args.curr_type
local routeLoc = args.curr_province
return string.format(
frame:preprocess(
[[{{s-start}}
|-
! colspan=3 | %s
|- style="text-align: center;"
| style="width:30%%;" | Previous route<br>%s
| style="width:40%%;" | %s
| style="width:30%%;" | Next route<br>%s
{{s-end}}]]
),
types[type] or args.title or error('Type or title missing'),
edgeColumn('prev', routeLoc, args),
showRoute(route, routeType, routeLoc, routeLoc),
edgeColumn('next', routeLoc, args)
)
end
return p