Module:Sandbox/User:Riblet15/Tabber: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(Created page with "local p = {} -- Access point for other modules -- argument format: {{"tab 1 label", "tab 1 content"}, {"tab 2 label", "tab 2 content"}, {"etc", "..."}} function p.tabber(tabs) preprocess = preprocess == nil and true or preprocess -- if no preprocess defined, set to true local tabber = "" for i, tab in ipairs(tabs) do if i > 1 then tabber = tabber .. "|-|" end tabber = tabber .. mw.text.trim(tab[1]) .. '=' .. tab[2] end return mw.getCurrentFrame():callParse...") |
(No difference)
|
Latest revision as of 01:13, 17 October 2024
Module documentation
This documentation is transcluded from Template:Module sandbox/doc. [edit] [history] [purge]
This module is a sandbox for Riblet15. It can be used to test changes to existing modules, prototype new modules, or just experimenting with lua features.
Invocations of this sandbox should be kept in userspace; if the module is intended for use in other namespaces, it should be moved out of the sandbox into a normal module and template.
This default documentation can be overridden by creating the /doc subpage of this module, as normal.
local p = {}
-- Access point for other modules
-- argument format: {{"tab 1 label", "tab 1 content"}, {"tab 2 label", "tab 2 content"}, {"etc", "..."}}
function p.tabber(tabs)
preprocess = preprocess == nil and true or preprocess -- if no preprocess defined, set to true
local tabber = ""
for i, tab in ipairs(tabs) do
if i > 1 then
tabber = tabber .. "|-|"
end
tabber = tabber .. mw.text.trim(tab[1]) .. '=' .. tab[2]
end
return mw.getCurrentFrame():callParserFunction( '#tag', { 'tabber', tabber } )
end
-- [[Template:Tabber]]
function p.main(frame)
local args = frame:getParent().args
local i = 1
local tabs = {}
while args['tab'..tostring(i)] do
local tab = 'tab'..tostring(i)
table.insert(tabs, { args[tab], args[tab..'content'] or ''})
i = i+1
end
return p.tabber(tabs)
end
return p