<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.cultopedia.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ALink_if_exists</id>
	<title>Module:Link if exists - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.cultopedia.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ALink_if_exists"/>
	<link rel="alternate" type="text/html" href="https://www.cultopedia.org/index.php?title=Module:Link_if_exists&amp;action=history"/>
	<updated>2026-04-05T22:08:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.5</generator>
	<entry>
		<id>https://www.cultopedia.org/index.php?title=Module:Link_if_exists&amp;diff=1664&amp;oldid=prev</id>
		<title>imported&gt;Hike395: Restored revision 1323871754 by Hike395 (talk): Restore after fixing Template:Category link if exists</title>
		<link rel="alternate" type="text/html" href="https://www.cultopedia.org/index.php?title=Module:Link_if_exists&amp;diff=1664&amp;oldid=prev"/>
		<updated>2025-11-25T02:37:32Z</updated>

		<summary type="html">&lt;p&gt;Restored revision 1323871754 by &lt;a href=&quot;/index.php/Special:Contributions/Hike395&quot; title=&quot;Special:Contributions/Hike395&quot;&gt;Hike395&lt;/a&gt; (&lt;a href=&quot;/index.php?title=User_talk:Hike395&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User talk:Hike395 (page does not exist)&quot;&gt;talk&lt;/a&gt;): Restore after fixing &lt;a href=&quot;/index.php?title=Template:Category_link_if_exists&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Template:Category link if exists (page does not exist)&quot;&gt;Template:Category link if exists&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;strict&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local function titleExistsUnprotected(titleObject)&lt;br /&gt;
    return titleObject.exists&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- test for title existing&lt;br /&gt;
-- if we get an error accessing titleObject.exists, assume it doesn&amp;#039;t exist&lt;br /&gt;
local function titleExists(titleObject)&lt;br /&gt;
    local success, exists = pcall(titleExistsUnprotected, titleObject)&lt;br /&gt;
    return success and exists&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
    local title = args[1]&lt;br /&gt;
    if not title then&lt;br /&gt;
        return title&lt;br /&gt;
    end&lt;br /&gt;
    local display = args[2] or title&lt;br /&gt;
    title = args.prefix and args.prefix..&amp;#039;:&amp;#039;..title or title&lt;br /&gt;
    local titleObject = mw.title.new(title, args.nsp)&lt;br /&gt;
    local result = &amp;#039;&amp;#039;&lt;br /&gt;
    if titleObject and titleExists(titleObject) then&lt;br /&gt;
       -- use prefix only if args[2] is empty/false&lt;br /&gt;
        display = args[2] or title&lt;br /&gt;
        result = result..&amp;#039;[[&amp;#039;&lt;br /&gt;
        result = result..(titleObject.namespace ~= 0 and &amp;#039;:&amp;#039; or &amp;#039;&amp;#039;)&lt;br /&gt;
        result = result..(titleObject.fullText ~= display and titleObject.fullText..&amp;#039;|&amp;#039; or &amp;#039;&amp;#039;)&lt;br /&gt;
        result = result..display..&amp;#039;]]&amp;#039;&lt;br /&gt;
    elseif not args.hide_display then&lt;br /&gt;
        result = result..(args.color and &amp;#039;&amp;lt;span style=&amp;quot;color:&amp;#039;..args.color..&amp;#039;&amp;quot;&amp;gt;&amp;#039; or &amp;#039;&amp;#039;)&lt;br /&gt;
        result = result..display&lt;br /&gt;
        result = result..(args.color and &amp;#039;&amp;lt;/span&amp;gt;&amp;#039; or &amp;#039;&amp;#039;)&lt;br /&gt;
    end&lt;br /&gt;
    return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
    local args = getArgs(frame)&lt;br /&gt;
    return p._main(args) or &amp;quot;&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Hike395</name></author>
	</entry>
</feed>