This module pulls data from road data strings, such as Module:Road data/strings/USA, and passes it through three functions that draw the necessary route marker images and displays the route name in {{Infobox road}}.

Output examples
Description Output Output (sandbox)
Florida Both Lua error at line 66: attempt to compare two nil values. Lua error in Module:Infobox_road/route/sandbox at line 66: attempt to compare two nil values.
No parameters
Only |marker_image=
Florida |marker_image=none

State Road A1A

State Road A1A

Only |name=

Autoroute 10

Autoroute 10

Australia

National Highway 31

National Highway 31 marker

National Highway 31

National Highway 31 marker

New Zealand

State Highway 2 marker

State Highway 2

State Highway 2 marker

State Highway 2

Interstate |name=
Interstate (Infobox road small) Lua error at line 66: attempt to compare two nil values. Lua error in Module:Infobox_road/route/sandbox at line 66: attempt to compare two nil values.
France
UK
Brazil
Chile Lua error at line 66: attempt to compare two nil values. Lua error in Module:Infobox_road/route/sandbox at line 66: attempt to compare two nil values.
BC Lua error at line 66: attempt to compare two nil values. Lua error in Module:Infobox_road/route/sandbox at line 66: attempt to compare two nil values.
Saskatchewan
Quebec
Ontario
ON Secondary
ON Tertiary
NWT

Inuvik–Tuktoyaktuk Highway marker

Inuvik–Tuktoyaktuk Highway

Inuvik–Tuktoyaktuk Highway marker

Inuvik–Tuktoyaktuk Highway

Manitoba

Provincial Trunk Highway 3

Provincial Trunk Highway 3

Tennessee Dual Lua error at line 66: attempt to compare two nil values. Lua error in Module:Infobox_road/route/sandbox at line 66: attempt to compare two nil values.
DE/MD Dual Lua error at line 66: attempt to compare two nil values. Lua error in Module:Infobox_road/route/sandbox at line 66: attempt to compare two nil values.
Puerto Rico type=PR Lua error at line 66: attempt to compare two nil values. Lua error in Module:Infobox_road/route/sandbox at line 66: attempt to compare two nil values.
Puerto Rico type=Urban
Wisconsin Lua error at line 66: attempt to compare two nil values. Lua error in Module:Infobox_road/route/sandbox at line 66: attempt to compare two nil values.
North Carolina Lua error at line 66: attempt to compare two nil values. Lua error in Module:Infobox_road/route/sandbox at line 66: attempt to compare two nil values.
Nevada BLSR Lua error at line 66: attempt to compare two nil values. Lua error in Module:Infobox_road/route/sandbox at line 66: attempt to compare two nil values.
Utah BLSR Lua error at line 66: attempt to compare two nil values. Lua error in Module:Infobox_road/route/sandbox at line 66: attempt to compare two nil values.
Texas Both Lua error at line 66: attempt to compare two nil values. Lua error in Module:Infobox_road/route/sandbox at line 66: attempt to compare two nil values.
Texas tollway

Pres. George Bush Turnpike marker

Pres. George Bush Turnpike

Pres. George Bush Turnpike marker

Pres. George Bush Turnpike

1926 USH
1948 USH
Special route
Special route (style=small)
Alaska |marker_image=
DC

District of Columbia Route 295 marker

District of Columbia Route 295

District of Columbia Route 295 marker

District of Columbia Route 295

Mexico

Federal Highway 40D marker

Federal Highway 40D

Federal Highway 40D marker

Federal Highway 40D

Sonora

State Highway 149 marker

State Highway 149

State Highway 149 marker

State Highway 149

GRR

Great River Road marker

Great River Road

Great River Road marker

Great River Road

Tour

Lake Michigan Circle Tour marker

Lake Michigan Circle Tour

Lake Michigan Circle Tour marker

Lake Michigan Circle Tour

Turnpike

Kansas Turnpike marker

Kansas Turnpike

Kansas Turnpike marker

Kansas Turnpike

County road

County Road Z36 marker

County Road Z36

County Road Z36 marker

County Road Z36

Parish road

Parish Road 16 marker

Parish Road 16

Parish Road 16 marker

Parish Road 16

CSAH

County State-Aid Highway 81 marker

County State-Aid Highway 81

County State-Aid Highway 81 marker

County State-Aid Highway 81

Secondary

Secondary Highway 206 marker

Secondary Highway 206

Secondary Highway 206 marker

Secondary Highway 206

Supplemental
Oregon

Oregon Route 35 marker

Oregon Route 35

Oregon Route 35 marker

Oregon Route 35

Oregon Highway

John Day Highway No. 5

John Day Highway No. 5

Belgium Lua error at line 107: bad argument #1 to 'wikitext' (string or number expected, got boolean). Lua error in Module:Infobox_road/route/sandbox at line 107: bad argument #1 to 'wikitext' (string or number expected, got boolean).
Belgium Lua error at line 107: bad argument #1 to 'wikitext' (string or number expected, got boolean). Lua error in Module:Infobox_road/route/sandbox at line 107: bad argument #1 to 'wikitext' (string or number expected, got boolean).

local p = {} 

local format = mw.ustring.format
require('strict')
local getArgs = require('Module:Arguments').getArgs	
local parserModule = require 'Module:Road data/parser'
local parser = parserModule.parser

local function banner(args, style)
	if args.marker_image then return nil end
	
	local bannerSize
		if style == 'small' then
			bannerSize = "40px"
		else
			bannerSize = "70px"
		end
	
	local shield = parser(args, 'banner')
	local alt = parser(args, 'banner')

	if not shield or shield == '' then
		return nil
	else
		return string.format('[[File:%s|%s|alt=%s]]', shield, bannerSize, alt)
	end
end



local function shield(args, style)

	if args.marker_image then return args.marker_image end
	
	local horizontalSize
	local verticalSize
		if style == 'small' then
			horizontalSize = "90x40px"
			verticalSize = "40x90px"
		else
			horizontalSize = "150x70px"
			verticalSize = "70x150px"
		end

	local shield = parser(args, 'shieldmain') or parser(args, 'shield') or ''
	
	local label = parser(args, 'name') or parser(args, 'abbr') or ''
	local alt = label .. ' marker'
	local orientation = parser(args, 'orientation')
	
	local function simpleSize(args)
		if orientation and orientation == 'upright' then
			return verticalSize
		else
			return horizontalSize
		end
	end
	
	local function shield_size(image_name, orientation)
		local image = 'File:' .. image_name
		local title = mw.title.new(image)

		local width = title.file.width
		local height = title.file.height
		
		if (orientation and orientation == 'upright') or height > width then
			return verticalSize
		else
			return horizontalSize
		end
	end
	
	
	
	if not shield or shield == '' then
		return nil
	elseif type(shield) == 'table' then
		local res = {}
		local sizes = {}
		for i,v in ipairs(shield) do
			sizes[i] = v
			res[i] = string.format('[[File:%s|%s|alt=%s]]', v, shield_size(v), alt)
		end
    	return table.concat(res, ' ')
	else
		return string.format('[[File:%s|%s|alt=%s]]', shield, simpleSize(args), alt)
	end
end

-- Links/abbreviations
local function name(args)
	local name = args.name or parser(args, 'name') or parser(args, 'abbr')
	return name
end

function p._routeInfo(args)
	
	local style = args.style
	local banner = banner(args, style)
	local shield = shield(args, style)
	local name = name(args)

	if not args.type and not args.route and not args.name and not args.marker_image then
		local container = nil
	else local container = mw.html.create('div'):cssText('text-align:center;')
		if shield == nil or args.marker_image == 'none' or args.name and not args.marker_image and not args.type and not args.route then 
			container:tag('p'):cssText('margin:0.1em;'):wikitext(name)
		elseif args.marker_image ~= '' and args.name == '' or args.name == nil and not args.type and not args.route then
			container:tag('p'):cssText('margin:0.1em;'):wikitext(shield)
		elseif args.country == 'AUS' then
			container:tag('p'):cssText('margin:0.1em;'):wikitext(name)
			container:tag('p'):cssText('margin:0.1em 0 0 0;'):wikitext(shield)
		else
			container:tag('p'):cssText('margin:0.1em 0 0 0;'):wikitext(banner)
			container:tag('p'):cssText('margin:0 0 0.1em;'):wikitext(shield)
			container:tag('p'):cssText('margin:0.1em;'):wikitext(name)
		end
		return tostring(container)
	end
end

function p.routeInfo(frame)
	local args = getArgs(frame)
	return p._routeInfo(args);
end

function p._shields(args)
	
	local style = args.style
	local banner = banner(args, style)
	local shield = shield(args, style)

	if not args.type and not args.route and not args.name and not args.marker_image then
		local container = nil
	else local container = mw.html.create('div'):cssText('text-align:center; display: inline-block; vertical-align: baseline; line-height: 0;')
		container:tag('p'):cssText('margin:0.1em 0 0 0;'):wikitext(banner)
		container:tag('p'):cssText('margin:0 0 0.1em;'):wikitext(shield)
	return tostring(container)
	end
end

function p.shields(frame)
	local args = getArgs(frame)
	return p._shields(args);
end

return p