Module:Variable arguments

From Stalburg Wiki
Jump to navigation Jump to search

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.breadcrumb(frame)
	local args = mArguments.getArgs(frame, {
    	parentOnly = true
    })
	local out_str = ""
	local i = 0

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

    out_str = out_str:sub(1, -11)
	
	if out_str == "" or out_str == nil then
		out_str = "[[{{#titleparts: {{FULLPAGENAME}}|-1}}]]"
	end
	
	out_str = "<div id=\"contentSub\">"
		.. "<div style=\"margin: 0.5em;\"></div>"
		.. "<div class=\"nomobile\" style=\"margin: -0.8em;\"></div>"
		.. "<div style=\"margin: 0em;\">"
		.. string.format("<span class=\"subpages\">&lt; %s</span>", out_str)
		.. "</div></div>"
	return frame:preprocess(out_str)
end

return p