Module:Lua banner

Wiktionary වෙතින්

This module implements the {{uses lua}} template.

Usage from wikitext[සංස්කරණය]

This module cannot be used directly from wikitext. It can only be used through the {{lua}} template. Please see the template page for documentation.

Usage from Lua modules[සංස්කරණය]

To use this module from other Lua modules, first load the module.

local mLuaBanner = require('Module:Lua banner')

You can then generate a side box using the _main function.

mLuaBanner._main(args)

The args variable should be a table containing the arguments to pass to the module. To see the different arguments that can be specified and how they affect the module output, please refer to the {{lua}} template documentation.

Tracking category[සංස්කරණය]


-- 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
"https://si.wiktionary.org/w/index.php?title=Module:Lua_banner&oldid=165736" වෙතින් සම්ප්‍රවේශනය කෙරිණි