Module:Variable arguments: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
ArrowHead294 (talk | contribs)
New list for of arbitrary-argument template functions
 
ArrowHead294 (talk | contribs)
mNo edit summary
Line 1: Line 1:
local mArguments = require("Module:Arguments")
local mArguments = require("Module:Arguments")
local p = {}
local p = {}
function p.list(frame)
    local args = mArguments.getArgs(frame, {
    parentOnly = true
    })
local out_str = "<ul>\n"
for k, v in pairs(args) do
out_str = out_str .. "<li>" .. v .. "</li>\n"
end
out_str = out_str .. "</ul>"
return out_str
end


function p.modlink(frame)
function p.modlink(frame)

Revision as of 16:08, 19 September 2024

Module documentation[view] [edit] [history] [purge]
This module should not be invoked directly; use its corresponding templates instead.

This module is used to store functions for templates that take a variable number of arguments but do not use Module:Labelled list hatnote:

Introspection summary for Module:Variable arguments 
Functions provided (2)
Line Function Params
4 list (invokable) (frame)
16 modlink (invokable) (frame)
Lua modules required (1)
Variable Module Functions used
mArguments Module:Arguments getArgs

No function descriptions were provided. The Lua code may have further information.


local mArguments = require("Module:Arguments")
local p = {}

function p.list(frame)
    local args = mArguments.getArgs(frame, {
    	parentOnly = true
    })
	local out_str = "<ul>\n"
	for k, v in pairs(args) do
		out_str = out_str .. "<li>" .. v .. "</li>\n"
	end
	out_str = out_str .. "</ul>"
	return out_str
end

function p.modlink(frame)
    local args = mArguments.getArgs(frame, {
    	parentOnly = true
    })
	local out_str = ""
	local i = 0
	for k, v in pairs(args) do
		out_str = out_str .. "[[Module:" .. v .. "]]" .. ", "
		i = k
	end
	out_str = out_str:sub(1, -3)
		.. " &ndash; The "
		.. string.gsub("module that implement", "()", {[((i > 1) and {7} or {22})[1]] = "s"})
		.. " the functionality."
	return out_str
end

return p