Module:Message box: Difference between revisions

ony load Category handler when needed, requested on talk page
(change span to div to reduce lint errors)
(ony load Category handler when needed, requested on talk page)
Line 5:
require('Module:No globals')
local getArgs
local categoryHandler = require('Module:Category handler')._main
local yesno = require('Module:Yesno')
 
Line 109 ⟶ 108:
obj.categories = {}
obj.classes = {}
-- For lazy loading of [[Module:Category handler]].
obj.hasCategories = false
 
return setmetatable(obj, MessageBox)
Line 122 ⟶ 123:
cat = string.format('[[Category:%s]]', cat)
end
self.hasCategories = true
self.categories[ns] = self.categories[ns] or {}
table.insert(self.categories[ns], cat)
Line 429 ⟶ 431:
 
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
-- [[Module:Category handler]].
local categoryHandler = return require('Module:Category handler')._main{
return categoryHandler{
main = table.concat(self.categories[0] or {}),
template = table.concat(self.categories[10] or {}),
Anonymous user