Skip to content

Module:Stops

From Whitecoast City Railway Wiki

Documentation for this module may be created at Module:Stops/doc

-- The stops of a route, drawn as a line with a dot at each: {{Stops}}.
local p = {}

function p.main( frame )
	local args = frame:getParent().args
	local link = mw.ustring.lower( mw.text.trim( args.link or '' ) ) ~= 'no'
	local list = mw.html.create( 'ol' ):addClass( 'wcr-stops' )
	local count = 0
	local i = 1
	while args[ i ] do
		local stop = mw.text.trim( args[ i ] )
		if stop ~= '' then
			-- Linked unless it is linked already, or has more than a name.
			if link and not stop:find( '[[', 1, true ) then
				stop = '[[' .. stop .. ']]'
			end
			list:tag( 'li' ):wikitext( stop )
			count = count + 1
		end
		i = i + 1
	end
	if count == 0 then
		return '<strong class="error">Stops: give at least one stop.</strong>'
	end
	return tostring( list )
end

return p