Module:Variable arguments
Jump to navigation
Jump to search
Documentation transcluded from /doc
Documentation transcluded from /doc
This module is used to store functions for templates that take a variable number of arguments but do not use Module:Labelled list hatnote:
local mArguments = require("Module:Arguments")
local p = {}
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 = i + 1
end
out_str = out_str:sub(1, -3)
if out_str == "" then
out_str = "[[Module:" .. frame:preprocess("{{ROOTPAGENAME}}") .. "]]"
end
out_str = out_str
.. " – the "
.. string.gsub("module that implement", "()", {[((i > 1) and {7} or {22})[1]] = "s"})
.. " the functionality."
return out_str
end
function p.nwr(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 .. "<span style=\"white-space: nowrap;\">" .. string.gsub(v, "^%s*(.-)%s*$", "%1") .. "</span>, "
i = i + 1
end
out_str = out_str:sub(1, -3)
return out_str
end
function p.wikipedia(frame)
local args = mArguments.getArgs(frame, {
parentOnly = true
})
local out_str = ""
local i = 0
local root_page_name = frame:preprocess("{{FULLROOTPAGENAME}}")
for k, v in pairs(args) do
v = string.gsub(v, "^%s*(.-)%s*$", "%1")
if string.lower(v) ~= "false" and string.lower(v) ~= "true" then
out_str = out_str .. "<div style=\"margin-left: 10px;\">'''[[wikipedia:" .. v .. "|" .. v .. "]]'''</div>\n"
end
i = i + 1
end
if out_str == "" then
out_str = "<div style=\"margin-left: 10px;\">'''[[wikipedia:" .. root_page_name .. "|" .. root_page_name .. "]]'''</div>\n" .. out_str
end
out_str = "<div class=\"floatright\" style=\"border: 1px solid #aaa; font-size: 90%; background: #f9f9f9; width: 300px; padding: 4px; text-align: left;\">\n"
.. "<div style=\"float: left;\">[[File:Wikipedia-logo.png|44px|none|link=|alt=]]</div>\n"
.. "<div style=\"margin-left: 60px;\">English [[Wikipedia:Main Page|Wikipedia]] has " .. (i > 1 and "articles" or "an article") .." on:\n" .. out_str .. "</div></div>"
return out_str
end
return p