模組:Lua banner
可在模組:Lua banner/doc建立此模組的說明文件
-- This module implements the {{uses lua}} template.
local export = {}
local m_yesno = require("Module:yesno")
local m_list = require("Module:List")
local m_table = require("Module:table")
local m_messagebox = require("Module:Message box")
local m_tnt = require("Module:TNT")
local function format(msg)
return m_tnt.format("I18n/Lua banner", msg)
end
function export.main(frame)
local origArgs = frame:getParent().args
local args = {}
for k, v in pairs(origArgs) do
v = v:match("^%s*(.-)%s*$")
if v ~= "" then
args[k] = v
end
end
return export._main(args)
end
function export._main(args)
local modules = m_table.compressSparseArray(args)
local box = export.renderBox(modules, args)
return box
end
function export.renderBox(modules, args)
local boxArgs = {}
if #modules < 1 then
error(format("error_emptylist"))
else
local moduleLinks = {}
for i, module in ipairs(modules) do
moduleLinks[i] = string.format("[[:%s]]", module)
end
local moduleList = m_list.makeList("bulleted", moduleLinks)
boxArgs.text = format("header") .. "\n" .. moduleList
end
boxArgs.type = "notice"
boxArgs.small = true
boxArgs.image =
string.format("[[File:Lua-logo-nolabel.svg|30px|alt=%s|link=%s]]", format("logo_alt"), format("logo_link"))
return m_messagebox.main("mbox", boxArgs)
end
return export