Module:Recipe: Difference between revisions
From Growtopia Wiki
More actions
NekoPillow (talk | contribs) No edit summary |
NekoPillow (talk | contribs) No edit summary |
||
| Line 30: | Line 30: | ||
table.insert(o,v) | table.insert(o,v) | ||
end | end | ||
table.insert(s,"<div class='obtain recipebox'><tabber>". | table.insert(s,"<div class='obtain recipebox'><tabber>") | ||
table.insert(s,makeTabber(o)) | |||
table.insert(s,"</tabber></div>") | |||
return table.concat(s) | return table.concat(s) | ||
end | end | ||
return recipe | return recipe | ||
Revision as of 13:02, 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'><tabber>")
table.insert(s,makeTabber(o))
table.insert(s,"</tabber></div>")
return table.concat(s)
end
return recipe