Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Module:Infobox road/route/sandbox

From Wikipedia, the free encyclopedia
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 roadDataModule = require("Module:Road data/sandbox") -- REMOVE SANDBOX

local function shield(args, style)
	if args.marker_image then return args.marker_image end
	return roadDataModule.shield(args, 'main', style, true)
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 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('div'):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('div'):cssText('margin:0.1em;'):wikitext(shield)
		elseif args.country == 'AUS' then
			container:tag('div'):cssText('margin:0.1em;'):wikitext(name)
			container:tag('div'):cssText('margin:0.1em 0 0 0;'):wikitext(shield)
		else
			container:tag('div'):cssText('margin:0 0 0.1em;'):wikitext(shield)
			container:tag('div'):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 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('div'):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


function p._names(args)
	local name = name(args)
	return name
end

function p.names(frame)
	local args = getArgs(frame)
	return p._names(args);
end

return p