Module:Game shortened
From Inkipedia, the Splatoon wiki
Helper template that transforms the game argument into the shortened S form. For template chaining and code reduction. Will also help us when new game/expansions/formats are created.
If the game is not matched, the default argument is used instead if specified, otherwise "S".
Usage
game
|
Named or first positional, optional | The game that the cost belongs to. The following values are handled:
If game is not specified, the default argument will be used instead. | |||
default
|
Named or second positional, optional | If the game argument was not matched, uses this instead.
|
- Typical usage
{{Game shortened|<game>|<default>}}
{{Game shortened|Octo Expansion}}
->
OE
- Chained in another template that has the game parameter
{{Game shortened|{{{game|}}}}}
->
S
- Using the default parameter
{{Game shortened|Splatoon 3|S}}
->
S3
{{Game shortened|game=Splatoon 2|default=Splatoon}}
->
S2
- In files
[[File:{{Game shortened|Splatoon 3}}_Icon_Big_Run.svg|link=Big Run|30px]]
->
[[File:{{Game shortened|game=Splatoon 2|default=Splatoon 3}}_Splatfest_Logo.png|link=Splatfest|30px]]
->
See Also
local p = {} function p.getGame(arg, default) local OE = "OE" local SO = "SO" local SR = "SR" local S = "S" local S2 = "S2" local S3 = "S3" local abbrev = { ['OE'] = OE, ['Octo Expansion'] = OE, ['SR'] = SR, ['Salmon Run'] = SR, ['SO'] = SO, ['Side Order'] = SO, ['S'] = S, ['S1'] = S, ['Splatoon'] = S, ['Splatoon 1'] = S, ['S2'] = S2, ['Splatoon 2'] = S2, ['S3'] = S3, ['Splatoon 3'] = S3, } -- return the abbreviation from the game arg. -- If arg is nil then a default will be used. return abbrev[arg] or default or "S" end -- main to extract arg from frame function p.main(frame) local args = frame:getParent().args local arg = args['game'] or args[1] local default = args['default'] or args[2] return p.getGame(arg, default) end return p