<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FArtoria2e5%2FFallback%2Fdoc</id>
	<title>Module:Sandbox/Artoria2e5/Fallback/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FArtoria2e5%2FFallback%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Artoria2e5/Fallback/doc&amp;action=history"/>
	<updated>2026-05-27T13:41:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/Artoria2e5/Fallback/doc&amp;diff=145159&amp;oldid=prev</id>
		<title>imported&gt;Qwerfjkl (bot): Replaced deprecated &lt;source&gt; tags with &lt;syntaxhighlight&gt; (via WP:JWB)</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Artoria2e5/Fallback/doc&amp;diff=145159&amp;oldid=prev"/>
		<updated>2022-05-07T20:24:47Z</updated>

		<summary type="html">&lt;p&gt;Replaced deprecated &amp;lt;source&amp;gt; tags with &amp;lt;syntaxhighlight&amp;gt; (via &lt;a href=&quot;/index.php?title=WP:JWB&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;WP:JWB (page does not exist)&quot;&gt;WP:JWB&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Module rating |alpha}}&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
This module provides a function which adds fallback functionalities to a given table &amp;#039;&amp;#039;args&amp;#039;&amp;#039; according to the fallback sequence given in &amp;#039;&amp;#039;arg_aliases&amp;#039;&amp;#039;. Note that this module currently only supports indexing, i.e. &amp;lt;code&amp;gt;__index&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
;args: The table to add fallback functionalities.&lt;br /&gt;
;arg_aliases: A table of the form &amp;lt;code&amp;gt;{ [key] = { fallback1, fallback2... } }&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
The following snippet adds template parameter aliases to a metatable obtained from [[Module:Arguments]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
local makeFallback = require(&amp;#039;Module:Sandbox/Artoria2e5/Fallback&amp;#039;)&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local args = makeFallback(getArgs(frame), {&lt;br /&gt;
        [&amp;quot;foo_bar&amp;quot;] = {&amp;quot;foobar&amp;quot;, &amp;quot;foo&amp;quot;, &amp;quot;bar&amp;quot;}&lt;br /&gt;
    })&lt;br /&gt;
    -- Try calling this template with |foo=42.&lt;br /&gt;
    return (args[&amp;quot;foo_bar&amp;quot;] or &amp;quot;nothing here!&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following snippet shows basic usage of indexing fallback.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local makeFallback = require(&amp;#039;Module:Arguments/Fallback&amp;#039;)&lt;br /&gt;
table = {&lt;br /&gt;
    [&amp;quot;bar&amp;quot;] = &amp;quot;crunchy&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
makeFallback(table, {&lt;br /&gt;
    [&amp;quot;foo_bar&amp;quot;] = {&amp;quot;foobar&amp;quot;, &amp;quot;foo&amp;quot;, &amp;quot;bar&amp;quot;}&lt;br /&gt;
})&lt;br /&gt;
&lt;br /&gt;
return table[&amp;quot;foo_bar&amp;quot;]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following snippet creates a fallback list with all fallback names aliasing back to the main name.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local makeFallback = require(&amp;#039;Module:Sandbox/Artoria2e5/Fallback&amp;#039;)&lt;br /&gt;
table = {&lt;br /&gt;
    [&amp;quot;bar&amp;quot;] = &amp;quot;crunchy&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
makeFallback(table, {&lt;br /&gt;
    [&amp;quot;foo_bar&amp;quot;] = {&amp;quot;foobar&amp;quot;, &amp;quot;foo&amp;quot;, &amp;quot;bar&amp;quot;},&lt;br /&gt;
    [&amp;quot;foo&amp;quot;]     = {&amp;quot;foo_bar&amp;quot;}, &lt;br /&gt;
    [&amp;quot;foobar&amp;quot;]  = {&amp;quot;foo_bar&amp;quot;},&lt;br /&gt;
    [&amp;quot;bar&amp;quot;]     = {&amp;quot;foo_bar&amp;quot;}&lt;br /&gt;
})&lt;br /&gt;
return table[&amp;quot;foo&amp;quot;]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{#ifeq:{{SUBPAGENAME}}|sandbox | |&lt;br /&gt;
&amp;lt;!-- Categories below this line, please; interwikis at Wikidata --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Qwerfjkl (bot)</name></author>
	</entry>
</feed>