Jump to content

Module:NYC bus link/sandbox: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
test
fix
Line 23: Line 23:
local prose;
local prose;
if 'yes' or 'y' == args.prose then
if 'yes' or 'y' == args.prose then
return mw.text.listToText (result, ', ', 'and ');
return mw.text.listToText (result, ', ', ' and ');
else
else
return table.concat (result, ', ');
return table.concat (result, ', ');

Revision as of 22:47, 8 July 2018

require('Module:No globals');
local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.getLink(frame)
	local args = getArgs(frame);
	local city;
	
	if 'NYC' == args.city then
		city = 'New York City bus';
	elseif 'LI' == args.city then
		city = 'Long Island bus';
	elseif 'NJ' == args.city then
		city = 'New Jersey bus';
	end
		
	local result = {};
	for _, name in ipairs (args) do
		table.insert (result, table.concat ({'[[', name, ' (', city, ')|', name, ']]'}))
	end
	
	
	local prose;
	if 'yes' or 'y' == args.prose then
		return mw.text.listToText (result, ', ', ' and ');
	else
		return table.concat (result, ', ');
	end
end

return p;