Module:Anchor/sandbox2

From TSP Encyclopedia
Jump to navigation Jump to search

Documentation for this module may be created at Module:Anchor/sandbox2/doc

local p = {}

function p._main(args)
	local r = ""
	for k, v in pairs(args) do
		-- use gsub to trim whitespace
		if type(k) == "number" then
			local trimmed = mw.ustring.gsub(v, "%s+", "")
			if trimmed ~= "" then
				r = r .. '<span id="' .. trimmed .. '"></span>'
			end
		end
	end
	return r
end

function p.main(frame)
	local directResult = p._main(frame.args)
	if directResult ~= "" or frame:getParent() == nil then
		return directResult
	end
	return p._main(frame:getParent().args)
end

return p