Difference between revisions of "Template talk:Switch"
From The Urban Dead Wiki
Jump to navigationJump to search
m (Reverted edits by N O T R E D N A G (talk) to last revision by Klexur) |
|||
Line 1: | Line 1: | ||
Used to extend a variable as a parameter while maintaining a default value, allowing the selection of one of many predetermined values. | |||
==Example 1== | |||
Used alone: | |||
<pre> | |||
{{switch | |||
|{{CURRENTDOW}} | |||
|case: 1=Mon | |||
|case: 2=Tue | |||
|case: 3=Wed | |||
|case: 4=Thu | |||
|case: 5=Fri | |||
|case: 6=Sat | |||
|case: 0=Sun | |||
|default=No date | |||
}} | |||
</pre> | |||
Returns the abbreviated form of the current day. The name of today may be abbreviated as, ''{{switch | |||
|{{CURRENTDOW}} | |||
|case: 1=Mon | |||
|case: 2=Tue | |||
|case: 3=Wed | |||
|case: 4=Thu | |||
|case: 5=Fri | |||
|case: 6=Sat | |||
|case: 0=Sun | |||
|default=No date | |||
}}''. | |||
==Example 2== | |||
Used inside a template in conjuction with another variable: | |||
''Sample content for <nowiki>{{</nowiki>mytemplate<nowiki>}}</nowiki>'' | |||
<pre> | |||
... | |||
width: {{switch|{{{width}}}|case: big=500px|case: small=100px|default={{{width|250px}}} }}; | |||
... | |||
</pre> | |||
<nowiki>{{</nowiki>mytemplate<nowiki>}}</nowiki> outputs ... width: 250px; ... | |||
<nowiki>{{</nowiki>mytemplate|width=big<nowiki>}}</nowiki> outputs ... width: 500px; ... | |||
<nowiki>{{</nowiki>mytemplate|width=small<nowiki>}}</nowiki> outputs ... width: 100px; ... | |||
<nowiki>{{</nowiki>mytemplate|width=86px<nowiki>}}</nowiki> outputs ... width: 86px; ... | |||
Latest revision as of 19:56, 22 January 2014
Used to extend a variable as a parameter while maintaining a default value, allowing the selection of one of many predetermined values.
Example 1
Used alone:
{{switch |{{CURRENTDOW}} |case: 1=Mon |case: 2=Tue |case: 3=Wed |case: 4=Thu |case: 5=Fri |case: 6=Sat |case: 0=Sun |default=No date }}
Returns the abbreviated form of the current day. The name of today may be abbreviated as, Thu.
Example 2
Used inside a template in conjuction with another variable:
Sample content for {{mytemplate}}
... width: {{switch|{{{width}}}|case: big=500px|case: small=100px|default={{{width|250px}}} }}; ...
{{mytemplate}} outputs ... width: 250px; ...
{{mytemplate|width=big}} outputs ... width: 500px; ...
{{mytemplate|width=small}} outputs ... width: 100px; ...
{{mytemplate|width=86px}} outputs ... width: 86px; ...