Module:College football conference

From The Global Wiki
Jump to navigation Jump to search

Template:Module rating

Usage

This module is used by {{College football conference}}, and is not currently configured to be used directly outside of module space.

Updating the data tables

Alias

To add an alias for an existing school, edit Module:College football conference/alias. The format is <syntaxhighlight lang=lua> ["alias"] = "full name", </syntaxhighlight> where the full name is in Module:College football conference/data.

Data

To add a new school, edit Module:College football conference/data. The year keys should be one of the following formats, <syntaxhighlight lang=lua> ["year1-year2"] = "some conference", </syntaxhighlight> if the school was in the conference from year1 to year2 or <syntaxhighlight lang=lua> ["year"] = "some other conference", </syntaxhighlight> if the school was in the conference in year or <syntaxhighlight lang=lua> ["year-"] = "the current conference", </syntaxhighlight> if the school was in the conference from year to present or <syntaxhighlight lang=lua> ["-year"] = "the first conference", </syntaxhighlight> if the school was in the conference from the beginning of time until year.

If you need help making your changes, please ask at Template talk:College football conference.


-- this module implements [[Template:College football conference]]

local p = {}

function p._main(year, school)
	if school then
		local data = require('Module:College football conference/data')
		local alias = require('Module:College football conference/alias')
		year = tonumber(year) or 0
		local t = data[alias[school] or school]
		if not t then
			return "N/A"
		end
		for k,v in pairs(t) do
			k = mw.ustring.gsub(k, '^%s*(%d+)%s*$', '%1-%1')
			if k:match('^%s*%d*[^%d]%d*%s*$') then
				local y1 = mw.ustring.gsub(k, '^%s*(%d*)[^%d](%d*)%s*$', '%1')
				local y2 = mw.ustring.gsub(k, '^%s*(%d*)[^%d](%d*)%s*$', '%2')
				y1 = tonumber(y1) or year
				y2 = tonumber(y2) or year
				if year >= y1 and year <= y2 then
					return v
				end
			end
		end
		return "—"
	end
	return "N/A"
end

function p.main(frame)
	local args = frame:getParent().args
	return p._main(args['year'], args['college'])
end

return p