Module:sandbox: difference between revisions

From Wiktionary, the free dictionary
Jump to navigation Jump to search
Content deleted Content added
fix
testing replicability of weird error in Module:parameters as used by Module:headword/templates
Line 4: Line 4:


function export.show(frame)
function export.show(frame)
local n = -1
local plain_param = {}
local list_with_holes = {list = true, allow_holes = true}
local i = 0
local iter = ipairs(t)
local params = {
[1] = {required = true, default = "und"},
while i do
i = iter(t, i)
["sc"] = plain_param,
["cat sc"] = plain_param,
n = n + 1
["sort"] = plain_param,
[2] = {required = true, default = "nouns"},
["cat2"] = plain_param,
["cat3"] = plain_param,
["cat4"] = plain_param,
["head"] = {list = true, allow_holes = true, default = ""},
["id"] = plain_param,
["tr"] = list_with_holes,
["ts"] = list_with_holes, -- causes args["falt"] to vanish
["g"] = {list = true},
[3] = list_with_holes,
["f=accel"] = list_with_holes,
["f=request"] = list_with_holes,
["f=alt"] = list_with_holes,
["f=sc"] = list_with_holes,
["f=id"] = list_with_holes,
["f=tr"] = list_with_holes,
["f=g"] = list_with_holes,
["f=qual"] = list_with_holes,
["f=nolink"] = {list = true, allow_holes = true, type = "boolean"},
["f=lang"] = list_with_holes,
}
for k, v in pairs(params) do
if k == "f=alt" then
return "Success! <code>f=alt</code> parameter was found!"
end
end
end
return n
return "Error! <code>f=alt</code> parameter was invisible!"
end
end



Revision as of 05:44, 12 March 2018

Module sandbox for tests. The main function is show.

If you want to keep your test module as private, please create page in format: Module:User:(username)/(module_name).


Success! f=alt parameter was found!


local export = {}

local t = { 'a', 'b', 'c' }

function export.show(frame)
	local plain_param = {}
	local list_with_holes = {list = true, allow_holes = true}
	local params = {
		[1] = {required = true, default = "und"},
		["sc"] = plain_param,
		["cat sc"] = plain_param,
		["sort"] = plain_param,
		
		[2] = {required = true, default = "nouns"},
		["cat2"] = plain_param,
		["cat3"] = plain_param,
		["cat4"] = plain_param,
		
		["head"] = {list = true, allow_holes = true, default = ""},
		["id"] = plain_param,
		["tr"] = list_with_holes,
		["ts"] = list_with_holes, -- causes args["falt"] to vanish
		["g"] = {list = true},
		
		[3] = list_with_holes,
		
		["f=accel"]   = list_with_holes,
		["f=request"] = list_with_holes,
		["f=alt"]     = list_with_holes,
		["f=sc"]      = list_with_holes,
		["f=id"]      = list_with_holes,
		["f=tr"]      = list_with_holes,
		["f=g"]       = list_with_holes,
		["f=qual"]    = list_with_holes,
		["f=nolink"]  = {list = true, allow_holes = true, type = "boolean"},
		["f=lang"]    = list_with_holes,
	}
	
	for k, v in pairs(params) do
		if k == "f=alt" then
			return "Success! <code>f=alt</code> parameter was found!"
		end
	end
	
	return "Error! <code>f=alt</code> parameter was invisible!"
end

return export