Module:Lua banner:修订间差异

删除的内容 添加的内容
修复 main3:手动构建列表,取消对 Module:List.renderList 的依赖
回到 main/main2 方案,renderBox 文字改为「此模板/页面基于以下Lua模块编写」
第5行:
 
local p = {}
 
function p.main3(frame)
local args = (require('Module:Arguments').getArgs(frame))
local currentTitle = mw.title.getCurrentTitle()
local items = {}
for k, v in mTableTools.sparseIpairs(args) do
local title = mw.title.new(v, 828)
table.insert(items, string.format('* [[%s|%s]]', tostring(title), v))
end
if #items == 0 then
local subpageBlacklist = {
doc = true,
sandbox = true,
sandbox2 = true,
testcases = true
}
local fallback = subpageBlacklist[currentTitle.subpageText] and currentTitle.baseText or currentTitle.text
local title = mw.title.new(fallback, 828)
table.insert(items, string.format('* [[%s|%s]]', tostring(title), fallback))
end
return table.concat(items, '\n') .. p.renderTrackingCategories(args, args, currentTitle)
end
 
function p.main(frame)
第78行 ⟶ 第56行:
title = title.basePageTitle
end
local prefix
if title:inNamespaces(828, 829) then
boxArgs.textprefix = '此模块使用[[Wikipedia:Lua|Lua语言]]:\n' .. moduleList
elseif title.namespace == 10 then
prefix = '此模板'
else
prefix = '此页面'
boxArgs.text = '此模板使用[[Wikipedia:Lua|Lua语言]]:\n' .. moduleList▼
end
▲ boxArgs.text = prefix .. '此模板使用基于以下[[Wikipedia:Lua|Lua语言]]模块编写:\n' .. moduleList
end
boxArgs.type = 'notice'