Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.


From https://kenshi.fandom.com/wiki/Module:Tabber


local p = {}
local lib = require('Module:Feature')

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame)

	return p._main(args, frame)
end

function p._main(args, frame)
	if args == nil then return ''
	elseif type(args) ~= 'table' then return args
	end
	frame = frame or mw.getCurrentFrame()
	
	local tabber = mw.html.create('div'):addClass('wds-tabber')
	local labels = mw.html.create():tag('ul'):addClass('wds-tabs wds-tabs__wrapper' .. (args.no_border == nil and ' with-bottom-border' or ''))
	local contents = mw.html.create()
	local validTabs = 0
	
	local function addContent(container, content)
		if type(content) == 'string' then
			if args.nowiki then
				content = 
				frame:preprocess(
					mw.text.decode(
						mw.text.unstripNoWiki(
							content
						)
					)
				)
				container:wikitext(content) --plain string content encased in nowiki as to avoid bad mediawiki parsing
			else
				container:wikitext(content) --plain string content
			end
		elseif type(content) == 'table' and tostring(content) == 'table' then --table content 
			for _, subContent in ipairs(content) do
				addContent(container, subContent)
			end
		elseif type(content) == 'table' then container:node(content) --html content
		end
	end
	
	local i = 1
	local y = '1'
	while (args[i] and args[i+1]) or (args['label' .. y] and args['content' .. y]) do
		local label = args['label' .. y] or args[i]
		local content = args['content' .. y] or args[i+1]
		if lib.isNotEmpty(label) and lib.isNotEmpty(content) then
			validTabs = validTabs + 1
			labels
				:tag('li')
					:addClass('wds-tabs__tab' .. (i==1 and ' wds-is-current' or ''))
					:tag('div')
						:addClass('wds-tabs__tab-label')
						:wikitext(label)
						
			local contentContainer = 
			contents
				:tag('div')
					:addClass('wds-tab__content' .. (i==1 and ' wds-is-current' or ''))
			contentContainer:newline()
			addContent(contentContainer, content)
			contentContainer:newline()
		end
		i = i + 2 --unnamed go in pairs
		y = tostring(tonumber(y)+1)
	end
	
	tabber:node(labels)
	tabber:node(contents)
	
	return tabber
end

return p