Difference between revisions of "Module:Sandbox/Galobtter/Short description from country"

From blackwiki
Jump to navigation Jump to search
blackwiki>Galobtter
(aaargh)
blackwiki>Galobtter
m (Galobtter moved page Module:Short description from country to Module:Sandbox/Galobtter/Short description from country without leaving a redirect: doesn't work, move to sandbox for now)
(No difference)

Revision as of 17:56, 15 April 2018

Documentation for this module may be created at Module:Sandbox/Galobtter/Short description from country/doc

--given a pattern input like "country%d", if there is only one of it (excluding youth teams of the same country etc), give "nationality profession", e.g "German association football player"

--data = mw.loaddata("Module:Short description from country/data")
local p = {}

function p.main (frame)
	local getArgs = require('Module:Arguments').getArgs
	local args = getArgs(frame, {'frameOnly'})
	if args.disable == 'yes' then
		return
	end
	local parentArgs = getArgs(frame, {'parentOnly'})
	local name = args[1]
	local vals = {}
	local nationatString
	for m, n in pairs (parentArgs) do
		if string.find(m, "^"..name.."$") then
			n = string.gsub(n, " U[-]?%d+[|\]]?", "") --strip U23 etc
			nationString = n:match("^\[*(")
			if nationString then
				if n ~= nationString then
					return
				end
			else
				nationString = n
			end
		end
	end
	if nationString then return nationString.." "..args[2] end --data[nationString]
end
return p