Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Artoria2e5/Fallback/doc
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Example === The following snippet adds template parameter aliases to a metatable obtained from [[Module:Arguments]]. <syntaxhighlight lang=lua> local getArgs = require('Module:Arguments').getArgs local makeFallback = require('Module:Sandbox/Artoria2e5/Fallback') local p = {} function p.main(frame) local args = makeFallback(getArgs(frame), { ["foo_bar"] = {"foobar", "foo", "bar"} }) -- Try calling this template with |foo=42. return (args["foo_bar"] or "nothing here!") end return p </syntaxhighlight> The following snippet shows basic usage of indexing fallback. <syntaxhighlight lang=lua> local makeFallback = require('Module:Arguments/Fallback') table = { ["bar"] = "crunchy" } makeFallback(table, { ["foo_bar"] = {"foobar", "foo", "bar"} }) return table["foo_bar"] </syntaxhighlight> The following snippet creates a fallback list with all fallback names aliasing back to the main name. <syntaxhighlight lang=lua> local makeFallback = require('Module:Sandbox/Artoria2e5/Fallback') table = { ["bar"] = "crunchy" } makeFallback(table, { ["foo_bar"] = {"foobar", "foo", "bar"}, ["foo"] = {"foo_bar"}, ["foobar"] = {"foo_bar"}, ["bar"] = {"foo_bar"} }) return table["foo"] </syntaxhighlight> <includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | | <!-- Categories below this line, please; interwikis at Wikidata --> }}</includeonly>
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)