Module:ugly hacks

Hello, you have come here looking for the meaning of the word Module:ugly hacks. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:ugly hacks, but we will also tell you about its etymology, its characteristics and you will know how to say Module:ugly hacks in singular and plural. Everything you need to know about the word Module:ugly hacks you have here. The definition of the word Module:ugly hacks will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:ugly hacks, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module provides templates with functions which cannot be accessed any other way. When a function is not used, it should be removed.

Avoid using this module. If you find yourself writing a template which needs it, consider re-writing the template in Lua.

This module tracks templates in which its functions are used, using the tracking template mechanism; the tracking templates' names are of the form Wiktionary:tracking/ugly hacks/function_name and Wiktionary:tracking/ugly hacks/function_name/from template_name. To prevent it from becoming ineffective, wrappers around functions in this module should not be created; the {{#invoke:}} should be put directly where it is needed.

To further discourage their use, functions in this module are intentionally undocumented. To discover their usage purpose and syntax, please refer to mw:Extension:Scribunto/Lua reference manual.

Questions about this module and its possible replacements may be raised at Wiktionary:Grease pit.


local export = {}

function export.explode(frame)
	local args = frame.args
	local wanted_index, i = tonumber(args), 1
	for item in require("Module:string utilities").gsplit(args, args, true) do
		if i == wanted_index then
			return item
		end
		i = i + 1	
	end
	return ""
end

function export.substr(frame)
	local args = frame.args
	return require("Module:string utilities").sub(args or "", tonumber(args) or 1, tonumber(args) or -1)
end

function export.find(frame)
	local args = frame.args
	return require("Module:string utilities").find(args or "", args or "", 1, true) or ""
end

function export.find_pattern(frame)
	local args = frame.args
	return require("Module:string utilities").find(args or "", args or "", 1, false) or ""
end

function export.replace(frame)
	local args = frame.args
	return (require("Module:string utilities").gsub(args or "", args or "", args or ""))
end

function export.match(frame)
	local args = frame.args
	return (require("Module:string utilities").match(args or "", args or ""))
end

function export.is_valid_page_name(frame)
	return require("Module:pages").is_valid_page_name(frame.args) and "valid" or ""
end

local mt = {}

function mt:__index(k)
	local track = require("Module:debug/track")
	local parent = mw.getCurrentFrame():getParent()
	track("ugly hacks/" .. k)
	if parent then
		track("ugly hacks/" .. k .. "/from " .. parent:getTitle())
	end
	return export
end

return setmetatable({}, mt)