Jump to content

Module:PTV route

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by The Earwig (talk | contribs) at 05:49, 14 December 2015 (change name). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- This module implements [[Template:PTVBus]].

local data = mw.loadData('Module:PTVBus/data')
local p = {}

function p._main(args)
	local route = tonumber(args.route)
	if not route then
		return nil
	end
	local routeData = data[route]
	if not routeData then
		return nil
	end
	local url = 'http://ptv.vic.gov.au/route/view/' .. routeData.page
	local display
	if args.numtext then
		display = route
	elseif args.deftext then
		display = routeData.text
	else
		display = args.text
	end
	if display then
		return string.format('[%s %s]', url, display)
	else
		return string.format('[%s]', url)
	end
end

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {
		wrappers = 'Template:PTVBus',
	})
	return p._main(args)
end

return p