Content added Content deleted
(ony load Category handler when needed, requested on talk page) |
thegreatwar>Borderman m (1 revision imported) |
||
Line 5: | Line 5: | ||
require('Module:No globals') |
require('Module:No globals') |
||
local getArgs |
local getArgs |
||
⚫ | |||
local yesno = require('Module:Yesno') |
local yesno = require('Module:Yesno') |
||
Line 108: | Line 109: | ||
obj.categories = {} |
obj.categories = {} |
||
obj.classes = {} |
obj.classes = {} |
||
-- For lazy loading of [[Module:Category handler]]. |
|||
obj.hasCategories = false |
|||
return setmetatable(obj, MessageBox) |
return setmetatable(obj, MessageBox) |
||
Line 123: | Line 122: | ||
cat = string.format('[[Category:%s]]', cat) |
cat = string.format('[[Category:%s]]', cat) |
||
end |
end |
||
self.hasCategories = true |
|||
self.categories[ns] = self.categories[ns] or {} |
self.categories[ns] = self.categories[ns] or {} |
||
table.insert(self.categories[ns], cat) |
table.insert(self.categories[ns], cat) |
||
Line 431: | Line 429: | ||
function MessageBox:renderCategories() |
function MessageBox:renderCategories() |
||
if not self.hasCategories then |
|||
-- No categories added, no need to pass them to Category handler so, |
|||
-- if it was invoked, it would return the empty string. |
|||
-- So we shortcut and return the empty string. |
|||
return "" |
|||
end |
|||
-- Convert category tables to strings and pass them through |
-- Convert category tables to strings and pass them through |
||
-- [[Module:Category handler]]. |
-- [[Module:Category handler]]. |
||
return categoryHandler{ |
|||
⚫ | |||
main = table.concat(self.categories[0] or {}), |
main = table.concat(self.categories[0] or {}), |
||
template = table.concat(self.categories[10] or {}), |
template = table.concat(self.categories[10] or {}), |