Module:Variable arguments: Difference between revisions

mNo edit summary
mNo edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
local mArguments = require("Module:Arguments")
local mArguments = require("Module:Arguments")
local yesno = require("Module:Yesno")
local p = {}
local p = {}


Line 6: Line 7:
     parentOnly = true
     parentOnly = true
     })
     })
local out_str = ""
    local debugg = frame.args.debug_mode or args.debug_mode
local result = ""
local i = 0
local i = 0


Line 13: Line 15:
for k, v in pairs(args) do
for k, v in pairs(args) do
         pname = pname .. v
         pname = pname .. v
out_str = out_str .. string.format("[[%s|%s]] {{pipe}} ", pname, v)
result = result .. (v == debugg and "" or string.format("[[%s|%s]] {{pipe}} ", pname, v))
i = i + 1
i = i + 1
         pname = pname .. "/"
         pname = pname .. "/"
end
end


     out_str = out_str:sub(1, -11)
     result = result:sub(1, -11)
if out_str == "" then
if result == "" or result == nil then
out_str = "[[{{#titleparts: {{FULLPAGENAME}}|-1}}]]"
result = "[[{{#titleparts: {{FULLPAGENAME}}|-1}}]]"
end
end
out_str = "<div id=\"contentSub\">"
result = "<div id=\"contentSub\">\n"
.. "<div style=\"margin: 0.5em;\"></div>"
.. "<div id=\"mw-content-subtitle\">\n"
.. "<div class=\"nomobile\" style=\"margin: -0.8em;\"></div>"
.. "<div style=\"margin: 0.5em;\"></div>\n"
.. "<div style=\"margin: 0em;\">"
.. "<div class=\"nomobile\" style=\"margin: -0.8em;\"></div>\n"
.. string.format("<span class=\"subpages\">&lt; %s</span>", out_str)
.. string.format("<div class=\"subpages\" style=\"margin-top: -0.1em;\">&lt; <bdi dir=\"ltr\">%s</bdi></div>\n", result)
.. "</div></div>"
.. "</div>\n</div>{{#if: {{ARTICLESPACE}}||[[Category:Article subpages]]}}"
return frame:preprocess(out_str)
return frame:preprocess(yesno(debugg) == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result)
end
end


return p
return p

Latest revision as of 12:56, 13 May 2025

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 yesno = require("Module:Yesno")
local p = {}

function p.breadcrumb(frame)
	local args = mArguments.getArgs(frame, {
    	parentOnly = true
    })
    local debugg = frame.args.debug_mode or args.debug_mode
	local result = ""
	local i = 0

    local pname = ""
	
	for k, v in pairs(args) do
        pname = pname .. v
		result = result .. (v == debugg and "" or string.format("[[%s|%s]] {{pipe}} ", pname, v))
		i = i + 1
        pname = pname .. "/"
	end

    result = result:sub(1, -11)
	
	if result == "" or result == nil then
		result = "[[{{#titleparts: {{FULLPAGENAME}}|-1}}]]"
	end
	
	result = "<div id=\"contentSub\">\n"
		.. "<div id=\"mw-content-subtitle\">\n"
		.. "<div style=\"margin: 0.5em;\"></div>\n"
		.. "<div class=\"nomobile\" style=\"margin: -0.8em;\"></div>\n"
		.. string.format("<div class=\"subpages\" style=\"margin-top: -0.1em;\">&lt; <bdi dir=\"ltr\">%s</bdi></div>\n", result)
		.. "</div>\n</div>{{#if: {{ARTICLESPACE}}||[[Category:Article subpages]]}}"
	return frame:preprocess(yesno(debugg) == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result)
end

return p