Content deleted Content added
place main category in article even if |tempsort=no |
m code simplification and performance improvements |
||
Line 11:
Both templates had significant contributions from numerous others listed in the revision history tab of their respective pages.
--]]
local WRAPPER_TEMPLATE, catTag, catKey, args = 'Template:Asbox', '[[Category:%s]]', '%s|%s%s'
local
--Prevents dupli-cats... get it? Maybe not?▼
local Buffer = require('Module:Buffer')▼
--initializes variables required by both p.main and p.templatepage▼
rawset(t, i, v)▼
table.insert(t, i)▼
args = args or require('Module:Arguments').getArgs(frame, {▼
end▼
wrappers = WRAPPER_TEMPLATE▼
end}),
▲ --initializes variables required by both p.main and p.templatepage
page = page or mw.title.getCurrentTitle()▼
init = function(self, frame, page)
--Ensures demo parameter will never affect category() output for articles▼
self.demo = self.demo or page.namespace ~= 0 and args.demo or nil▼
▲ wrappers = WRAPPER_TEMPLATE
return args, page▼
▲end
end▼
▲--Prevents dupli-cats... get it? Maybe not?
▲p.cats = setmetatable({}, {__newindex = function(t, i, v)
▲ if not rawget(t, i) then
▲ rawset(t, i, v)
▲ table.insert(t, i)
▲ end
--[[
Formats category links. Stores them until called with cat.done=true
Line 38 ⟶ 36:
or a table of strings and/or tables containing parts. (See below)
]]
local function category(cat)
▲ local attention, link = 'Stub message templates needing attention'
▲ for _, v in ipairs((type(cat) == type'' or cat.t) and {cat} or cat) do
--[[
If v is a table:
Line 49 ⟶ 47:
]]
if v and v ~= true then--reject v = nil, false, or true
▲ p.demo and (v[1] or attention) or v.k or '',
▲ )
end
end
Line 253 ⟶ 244:
)
:node(args.note and
:tag'span'
:css{['font-style'] = 'normal', ['font-size'] = 'smaller'}
:wikitext(args.note)
:done()
)
:allDone()
Line 276 ⟶ 268:
output = mw.html.create()
:node(output)
:tag'small':wikitext(
(category{done = true}:gsub('(%[%[)(Category:)([^|%]]-)(%|)', '%1%2%3|%2%3%4'):gsub('(%[%[)(Category:)', '%1:%2'))
p.demo == 'doc' and p.demodoc or nil▼
):done()
else
--Checks for valid name; emulates original template's check using {{FULLPAGENAME:{{{name|}}}}}
Line 289 ⟶ 282:
end
end
return output:wikitext(not p.demo and category{done =
end
|