Soft launch: Soldier biographies and research notes vary in completeness. Prefer class-roster, NARA, newspapers, and other cited sources for contested facts — treat Research notes as leads, not settled history. Anyone can correct a page; contact us with questions.

Module:SplitCats

From Ritchie Boys Wiki
Revision as of 02:14, 19 August 2026 by Admin (talk | contribs) (Split semicolon team/class values into separate categories)
Jump to navigation Jump to search

Documentation for this module may be created at Module:SplitCats/doc

local p = {}

function p.categories(frame)
	local raw = frame.args[1] or ''
	local prefix = frame.args[2] or 'Class '
	raw = mw.ustring.gsub(raw, ';', ';')
	local out = {}
	for part in mw.text.gsplit(raw, ';', true) do
		part = mw.text.trim(part)
		if part ~= '' and not mw.ustring.find(part, ';', 1, true) then
			table.insert(out, '[[Category:' .. prefix .. part .. ']]')
		end
	end
	return table.concat(out)
end

function p.letterCategory(frame)
	local title = mw.title.getCurrentTitle()
	local first = mw.ustring.upper(mw.ustring.sub(title.text, 1, 1))
	if mw.ustring.match(first, '[A-Z]') then
		return '[[Category:Soldiers ' .. first .. ']]'
	end
	return '[[Category:Soldiers other]]'
end

return p