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

Module:Recipe: Difference between revisions

From Growtopia Wiki
NekoPillow (talk | contribs)
No edit summary
NekoPillow (talk | contribs)
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
local recipe = {}
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)  
function recipe.list(frame)  
local s = {}
local s = {}
table.insert(s,"<div class='obtain recipebox'><tabber>")
local o = {}
for k,v in ipairs(frame:getParent().args) do
for k,v in ipairs(frame:getParent().args) do
table.insert(s,"|-|"..k.."=")
table.insert(o,tostring(k))
table.insert(v)
table.insert(o,v)
end
end
table.insert(s,"</tabber></div>")
table.insert(s,"<div class='obtain recipebox'>")
table.insert(s,tostring(makeTabber(o)))
table.insert(s,"</div>")
return table.concat(s)
return table.concat(s)
end
end


return recipe
return recipe

Latest revision as of 13:09, 3 September 2024

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