Module:Higher education task force

This is an old revision of this page, as edited by Pharos (talk | contribs) at 20:04, 21 March 2025. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

--[[------------------------< generateTaskforceParameters >---------------------------------
Generates the WikiProject banner parameters for a comma-separated list of task force codes.

Parameters:
* frame: The frame object.

Returns:
* A string containing the WikiProject banner parameters for the task forces.
]]----------------------------------------------------------------------------
function p.generateTaskforceParameters(frame)
	local taskforcesStr = frame.args.taskforces
	if not taskforcesStr then
		return ""
	end

	local taskforceCodes = mw.text.split(taskforcesStr, ",", true, true) -- Split by comma, trim whitespace, remove empty strings
	local paramsStr = ""
	local tfCounter = 1

	for _, code in ipairs(taskforceCodes) do
		local tfData = p.getTaskForceData(code)
		if tfData then
			paramsStr = paramsStr .. string.format("|tf %d=yes", tfCounter)
			paramsStr = paramsStr .. string.format("|TF_%d_LINK=%s", tfCounter, tfData.link)
			paramsStr = paramsStr .. string.format("|TF_%d_NAME=%s", tfCounter, tfData.name)
			paramsStr = paramsStr .. string.format("|TF_%d_NESTED=%s", tfCounter, tfData.nested)
			paramsStr = paramsStr .. string.format("|TF_%d_IMAGE=%s", tfCounter, tfData.image)
			paramsStr = paramsStr .. string.format("|TF_%d_MAIN_CAT=%s", tfCounter, tfData.category)
			paramsStr = paramsStr .. "\n"
			tfCounter = tfCounter + 1
		end
	end

	return paramsStr
end