Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 13:09, 3 September 2024 by NekoPillow (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local recipe = {}

function makeTabber(args)
	local tabber = mw.html.create('div'):addClass('wds-tabber dev-tabber')
	local labels = tabber:tag('ul'):addClass('wds-tabs wds-tabs__wrapper')
	
	local idx = 1
	while true do
		local label = args[2 * idx - 1]
		local content = args[2 * idx]
		if label == nil then break end
		
		local is_current = idx == 1 and 'wds-is-current' or ''
		labels:tag('li'):addClass('wds-tabs__tab ' .. is_current)
			:attr('data-hash', label:gsub(' ', '_'))
			:tag('div'):addClass('wds-tabs__tab-label'):wikitext(label)
		
		tabber:tag('div'):addClass('wds-tab__content ' .. is_current):wikitext('\n' .. content)
		idx = idx + 1
	end
	
	return tabber
end

function recipe.list(frame) 
	local s = {}
	local o = {}
	for k,v in ipairs(frame:getParent().args) do
		table.insert(o,tostring(k))
		table.insert(o,v)
	end
	table.insert(s,"<div class='obtain recipebox'>")
	table.insert(s,tostring(makeTabber(o)))
	table.insert(s,"</div>")
	return table.concat(s)
end

return recipe