Module:Geography: Difference between revisions
| Robertbaxter (talk | contribs) No edit summary | Robertbaxter (talk | contribs)  No edit summary | ||
| Line 1: | Line 1: | ||
| local p = {} | local p = {} | ||
| function p.sharedPlace( | 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 | 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