Module:title/exists

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


local title_is_title_module = "Module:title/isTitle"
local title_new_title_module = "Module:title/newTitle"

local error = error
local format = string.format
local pcall = pcall
local require = require
local type = type

local at_limit

local function is_title(...)
	is_title = require(title_is_title_module)
	return is_title(...)
end

local function new_title(...)
	new_title = require(title_new_title_module)
	return new_title(...)
end

local function exists(title)
	return title.exists
end

--[==[
Receives a title object or string, and returns {true} if the page for the input title exists, or {false} if not.

By default, this function checks the {title.exists} key of the relevant title object, which increments the expensive function count. Normally, attempting to exceed the expensive function limit of 500 will result in an error being thrown, but this function will instead fall back to checking {title.content}, which does not increment the count. It is, however, considerably slower to check, and (unlike {title.exists}) will register as a page transclusion.

The {force_transclusion} flag may be set to force the use of transclusion ({title.content}) in all instances, which can be used to avoid incrementing the expensive function count; this is sometimes useful when making a large number of checks, as hitting the expensive function limit can be disruptive to other modules or templates.]==]
return function(title, force_transclusion)
	local title_type = type(title)
	if title_type == "string" then
		title = new_title(title)
		-- If it's an invalid string, return false.
		if not title then
			return false
		end
	elseif not is_title(title) then
		error(format("bad argument #1 to 'title/exists' (title object or string expected, got %s)", title_type), 2)
	end
	if not (force_transclusion or at_limit) then
		local success, result = pcall(exists, title)
		if success then
			return result
		end
		at_limit = true
	end
	return title.content ~= false
end