Module:Geography: Difference between revisions

From stencil.wiki
No edit summary
No edit summary
Line 1: Line 1:
local p = {}
local p = {}


function p.sharedPlace(list, inter)
function p.sharedPlace(frame)
-- Walk through the list and check if all items are identical.
    local args = frame.args or frame:getParent().args
-- If yes, return that item.
    local a = ""
-- If not, return inter if set or an empty string if not.
    local b = true
    for name in string.gmatch(args[1], "[^,]+") do
    name = name:gsub("^%s*(.-)%s*$", "%1")
if a == "" then
a = name
elseif a ~= name then
b = false
end
end
if b then return a else return "" end
end
end


function p.getRegion(country)
function p.getRegion(country)
-- Switch on the provided country and return the region string.
    -- Switch on the provided country and return the region string.
end
end


return p
return p

Revision as of 20:35, 2 January 2025

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

local p = {}

function p.sharedPlace(frame)
    local args = frame.args or frame:getParent().args
    local a = ""
    local b = true
    for name in string.gmatch(args[1], "[^,]+") do
    	name = name:gsub("^%s*(.-)%s*$", "%1")
		if a == "" then
			a = name
		elseif a ~= name then
			b = false
		end
	end
	if b then return a else return "" end
end

function p.getRegion(country)
    -- Switch on the provided country and return the region string.
end

return p