Module:Jct/city/sandbox
Appearance
< Module:Jct | city
![]() | This is the module sandbox page for Module:Jct/city (diff). |
local p = {}
local concat = table.concat
local insert = table.insert
local state
local function stateName(args)
local data = mw.loadData("Module:Jct/statename/sandbox") -- ON DEPLOY: Change to main module
local abbr = args.state or args.province
return data[args.country][abbr]
end
local function location(args, num)
local city = args["city" .. num]
local location = args["location" .. num]
local areadab = args["areadab" .. num]
local countydab = args["countydab" .. num]
if location then
return location
end
local parts = {}
insert(parts, "[[" .. city)
if areadab then
insert(parts, " (" .. areadab .. ")")
end
if countydab then
insert(parts, ", " .. countydab .. " County")
end
if state then
insert(parts, ", " .. state)
end
insert(parts, "|" .. city .. "]]")
return concat(parts)
end
function p.city(args)
state = stateName(args)
local cities = {}
local locationCount = 1
while args['city' .. locationCount] or args['location' .. locationCount] do
insert(cities, location(args, locationCount))
locationCount = locationCount + 1
end
return concat(cities, ', ')
end
return p