Module:Recipe: Difference between revisions
From Growtopia Wiki
More actions
NekoPillow (talk | contribs) No edit summary |
NekoPillow (talk | contribs) No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 30: | Line 30: | ||
table.insert(o,v) | table.insert(o,v) | ||
end | end | ||
table.insert(s,"<div class='obtain recipebox' | table.insert(s,"<div class='obtain recipebox'>") | ||
table.insert(s,makeTabber(o)) | table.insert(s,tostring(makeTabber(o))) | ||
table.insert(s," | 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