Module:Sandbox/PHansen/Fteam

Revision as of 10:36, 11 February 2015 by imported>PHansen ("country" ==> country +)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Sandbox/PHansen/Fteam/doc

local p = {}

--[[ Feb-2015
* Module:Sandbox/PHansen/Fteam ---  User:PHansen/Fteam --- 
* 'Fteam' : F for Football (soccer) --- team:  national teams for adults and youths (21, 19, 17) -  men and women
* Intention : to replace separate templates with one 'Fm/k/u' via Lua-module  - short form : 'Fmku' (men/women/youth)
]]


function p.main ( frame ) -- 

local country = frame.args[1] -- parameter from the template : country
local sex     = frame.args[2] -- parameter from the template : male or female  : m or k
local age     = frame.args[3] -- parameter from the template : 21, 19, 17, or ?  -  national team, youth 

local return_result = ""
local dummy = "dummy"
local error_msg = '<span class="error"><small>The format is &#123;{Fteam|country|sex|age}}</small></span>'


--Error
if country == nil or country == "" or country == "m" or country == "k" or country == "[0-9]" then 
	 return ( error_msg .. ' - `country` must be first parameter' )
end -- error if no country


-- if 'country' seemed OK then continue:
-- men AND adults (no age given)
if sex == "m" and age == "" then 
			-- was: [[{{{1}}}s fodboldlandshold|{{{1}}}]]
	return_result = "[[" .. country .. "s" .. " " .. "fodboldlandshold" .. "|" .. country .. "]]"
	return return_result
end -- adult, men


-- women AND adults (no age given)
if sex == "k" and age == "" then 
			--was: [[{{{1}}}s kvindefodboldlandshold|{{{1}}}]]
	return_result = "[[" .. country .. "s" .. " " .. "kvindefodboldlandshold" .. "|" .. country .. "]]"
	return return_result
end -- adult, women


-- men AND youth  (age given 17, 19, 21, or ?)
if age ~= "" and sex == "m" then 
	-- was: [[{{{1}}}s U/{{{2}}}-fodboldlandshold|{{{1}}} U/{{{2}}}]]
	return_result = "[[" .. country .. "s" .. " U/" .. age .. "-fodboldlandshold" .. "|" .. country .. " U/" .. age .. "]]"
	return return_result
end -- men AND youth  (age given 17, 19, 21, or ?)


-- women AND youth  (age given 17, 19, 21, or ?)
if age ~= "" and sex == "k" then 
	-- was: [[{{{1}}}s U/{{{2}}}-kvindefodboldlandshold|{{{1}}} U/{{{2}}}]]
	return_result = "[[" .. country .. "s" .. " U/" .. age .. "-kvindefodboldlandshold" .. "|" .. country .. " U/" .. age .. "]]"
	return return_result
end -- women AND youth  (age given 17, 19, 21, or ?)



end -- function p.main ( frame )


return p  -- export table