- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Difference between revisions of "Module:Tabber"
Jump to navigation
Jump to search
com>Ckwng m |
m (11 revisions imported) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
local BaseData = require('Module:BaseData') | local BaseData = require('Module:BaseData') | ||
− | |||
local Tabber = BaseData{ | local Tabber = BaseData{ | ||
− | |||
_separator = '\n|-|\n' | _separator = '\n|-|\n' | ||
} | } | ||
Line 10: | Line 8: | ||
data = data or {} | data = data or {} | ||
data._tabs = {} | data._tabs = {} | ||
+ | data.__tostring = self._tostring | ||
return self.__index.create(self, data) | return self.__index.create(self, data) | ||
end | end | ||
Line 17: | Line 16: | ||
end | end | ||
− | function Tabber: | + | function Tabber:_tostring() |
− | return | + | return mw.getCurrentFrame():preprocess('<tabber>' .. table.concat(self._tabs, self._separator) .. '</tabber>') |
end | end | ||
return Tabber | return Tabber |
Latest revision as of 12:34, 12 May 2021
Documentation for this module may be created at Module:Tabber/doc
local BaseData = require('Module:BaseData')
local Tabber = BaseData{
_separator = '\n|-|\n'
}
function Tabber:create(data)
data = data or {}
data._tabs = {}
data.__tostring = self._tostring
return self.__index.create(self, data)
end
function Tabber:add_tab(tab_name, tab_contents)
table.insert(self._tabs, tab_name .. '=' .. tab_contents)
end
function Tabber:_tostring()
return mw.getCurrentFrame():preprocess('<tabber>' .. table.concat(self._tabs, self._separator) .. '</tabber>')
end
return Tabber