Module:OrderedTabs
跳转到导航
跳转到搜索
local p = {}
local umatch = mw.ustring.match
function ExtractTabArgs(t)
local pack = {}
local pattern = [=[^(.+)(%d+)$]=]
for k,v in pairs(t) do
local typ,ind = umatch(k, pattern)
mw.log(typ,ind)
if typ and ind then
ind = tonumber(ind) or 0
typ = string.lower(typ)
if typ == "bt" or typ == "tab" or typ == "bticon" then
if not pack[ind] then pack[ind] = {} end
pack[ind][typ] = v
end
end
end
return pack
end
function p.Main(frame)
local args = (frame:getParent() and frame:getParent().args) or frame.args
local targs = ExtractTabArgs(args)
local ret = [[]]
for k,v in pairs(targs) do
local index = tonumber(k) or 0
if index ~= 0 then
mw.logObject(v)
if v.bt and v.tab then
local tabLabel =
mw.html.create("div")
:addClass("TabLabelText")
:wikitext( (v.bticon or [[]]) .. (v.bt or [[]]) )
:done()
local tabContent =
mw.html.create("div")
:addClass("TabContentText")
:wikitext(v.tab or [[]])
:done()
local tabRoot =
mw.html.create("div")
:addClass("Tab")
:node(tabLabel):newline():done()
:node(tabContent):newline():done()
:allDone()
mw.log(tabRoot)
ret = ret .. tostring(tabRoot) .. "\n"
end
end
end
return ret
end
return p