Jump to content

Module:NYC bus link and Module:NYC bus link/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
Replace Module:No globals with require( "strict" )
 
use require('strict') instead of require('Module:No globals')
 
Line 1: Line 1:
require("strict");
require('strict');
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local p = {}
local p = {}
Line 5: Line 5:
function p.getLink(frame)
function p.getLink(frame)
local args = getArgs(frame);
local args = getArgs(frame);
local result = {};
local city;
local city;
args.city = args.city:lower();
if 'NYC' == args.city then
if 'nyc' == args.city then
city = 'New York City bus';
city = 'New York City bus';
elseif 'li' == args.city then
elseif 'LI' == args.city then
city = 'Long Island bus';
city = 'Long Island bus';
elseif 'nj' == args.city then
elseif 'NJ' == args.city then
city = 'New Jersey bus';
city = 'New Jersey bus';
elseif 'columbia' == args.city then
city = 'Columbia Transportation'
elseif 'princeton' == args.city then
city = 'Tiger Transit'
else
return table.concat ({'<span style=\"font-size:100%; font-style:normal;\" class=\"error\">unexpected city: ', args.city, '</span>'})
end
end
local result = {};
for _, name in ipairs (args) do
for _, name in ipairs (args) do
table.insert (result, table.concat ({'[[', name, ' (', city, ')|', name, ']]'}))
table.insert (result, table.concat ({'[[', name, ' (', city, ')|', name, ']]'}))
end
end
if ('yes' == args.prose) or ('y' == args.prose) then
local prose;
return mw.text.listToText (result);
if 'yes' or 'y' == args.prose then
return mw.text.listToText (result, ', ', ' and ');
else
else
return table.concat (result, ', ');
return table.concat (result, ', ');