Module:Sandbox/BrandonXLF/3: Difference between revisions

Content deleted Content added
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 1:
-- Sandbox, do not delete
require('strict')
 
local p = {}
 
local getArgs = require('Module:Arguments').getArgs
Line 8 ⟶ 6:
local parser = parserModule.parser
 
local function routemakeRoute(route, routeType, routeLoc, currProvince)
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 route(route, routeType, routeLoc, currProvince)
local out = ''
local parserArgs = {
route = route,
type = routeType,
province = routeLoc
Line 43 ⟶ 35:
end
return "'''" .. out .. "'''"
end
 
local function navmakeNav(prefix, label, currProvince, args)
function p.route(frame)
return route(
frame.args[1],
frame.args.type,
frame.args.province,
frame.args.current_province or frame.args.province
)
end
 
local function nav(prefix, label, currProvince, args)
local index = 1
local out = ''
Line 68 ⟶ 51:
end
out = out .. routemakeRoute(route, routeType, routeLoc, currProvince)
index = index + 1
until not args[prefix .. index]
return label .. ' ' .. (index - 1 > 1 and 'routes' or 'route') .. '\n<br>' .. out
end
 
local p = {}
 
function p.route(frame)
return routemakeRoute(
frame.args[1],
frame.args.type,
frame.args.province,
frame.args.current_province or frame.args.province
)
end
 
function p.nav(frame)
return navmakeNav(
frame.args[1],
frame.args.label,
frame.args.current_province,
getArgs(frame, { parentOnly = true })
)
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
local prev, prevWord = nav('prev', routeLoc, args)
local next, nextWord = nav('next', routeLoc, args)
return string.format(
frame:preprocess(
[[{{s-start}}
|-
! colspan=3 | %s
|- style="text-align: center;"
| style="width: 30%%;" | Previous&nbsp;%s<br>%s
| style="width: 30%%;" | %s
| style="width: 30%%;" | Next&nbsp;%s<br>%s
{{s-end}}]]
),
types[type] or args.title or error('Type or title missing'),
prevWord,
prev,
route(route, routeType, routeLoc, routeLoc),
nextWord,
next
)
end