Template:Fn: Difference between revisions
No edit summary |
No edit summary Tag: 2017 source edit |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
<includeonly>{{#switch:{{{1|}}} | <includeonly>{{#switch:{{{1|}}} | ||
|the Brig=the Brig{{!}}the Brig | |Alistair Gordon Lethbridge-Stewart|the Brig|the Brigadier=the Brig{{!}}the Brig | ||
|The Brig=The Brig{{!}}The Brig | |The Brig|The Brigadier=The Brig{{!}}The Brig | ||
| | |Benton|John Benton|Sergeant Benton=John Benton{{!}}Benton | ||
| | |Yakes|Mike Yates=Mike Yates{{!}}Yates | ||
| | |||
| | |||
|Mike | |||
|Captain Yates=Mike Yates{{!}}Yates | |Captain Yates=Mike Yates{{!}}Yates | ||
|Alistair Gordon Lethbridge-Stewart=the Brig{{!}}the Brig | |Alistair Gordon Lethbridge-Stewart=the Brig{{!}}the Brig | ||
Line 13: | Line 9: | ||
|the Rani=the Rani | |the Rani=the Rani | ||
|the Monk=the Monk | |the Monk=the Monk | ||
|Jack's mother=Jack's mother | |||
|#default={{{1}}}{{!}}{{#explode:{{{1}}}| |0}} | |#default={{{1}}}{{!}}{{#explode:{{{1}}}| |0}} | ||
}} | }} | ||
</includeonly><noinclude>{{documentation}}[[Category:Coding utility templates]]</noinclude> | </includeonly><noinclude>{{documentation}}[[Category:Coding utility templates]]</noinclude> |
Latest revision as of 01:46, 14 January 2022
This template isn't super useful on its own. For instance, if you type {{fn|Martha Jones}}, you'll merely get Martha Jones|Martha — which doesn't do you a whole lot of good.
But, within templates, where you can preset the brackets, it's highly useful to automated processes.
Usage is along the lines of:
[[{{fn|{{{variable name}}}]]
In the typical infobox, you'll have a variable and value, which this template can usefully handle. For instance, within {{Infobox Individual}}, you have:
{|Infobox Individual |name=Leo Jones |sister=Martha Jones |sister-Tish Jones |}
If you set {{Infobox Individual}} to correctly process this input as an SMW variable — but want it to show only a linked first name, the guts of the code would be this:
[[sister::{{fn|{{{sister}}}}}]] [[sister::{{fn|{{{sister2}}}}}]]
This, when mixed with a tiny bit more formatting, would result in the following displaying in the infobox: Martha, Tish. Meanwhile, Property:Sister for Leo Jones would return Martha Jones and Tish Jones.
Exceptions[[edit source]]
Because this wiki covers the DWU, we have to make exceptions for characters who don't have normal names. In particular, the DWU has a lot of characters, starting with the titular one, whose names are in the format of "the <whatever>". Lucikly this template uses a #switch core, so we can easily set up exceptions, where we directly define how we want to handle certain, specific names to be handled — but then otherwise let the template cascade down to the #default way of doing things.
If you encounter a character who has an "odd" name, like Jack's mother (Kept Safe and Sound), you'll have to add an exception to the code of this template. To do so, just create a new line above the line that begins with |#default=. On that line, set the "odd" name equal to whatever term you'd like to use. So, for the example above, you'd just add this:
|Jack's mother (Kept Safe and Sound)=Jack's mother (Kept Safe and Sound){{!}}Jack's mother