Difference between revisions of "Template:HMS/doc"

From blackwiki
Jump to navigation Jump to search
imported>Swpb
m (→‎See also: clean up using AWB)
imported>DePiep
Line 32: Line 32:
 
Last example could be used to link to ship index (disambiguation) page
 
Last example could be used to link to ship index (disambiguation) page
  
=== Optional display control parameter ===
+
=== Format options parameter ===
There is an optional third parameter that controls which pieces of text are displayed in the article. Its value is treated as a binary number and will display the corresponding "bits".  So setting the 4's bit will display "HMS", setting the 2's bit will display the ship name, and setting the 1's bit will display the ID. If binary math isn't your thing, refer to these examples:
+
A fourth, unnamed parameter {{para|4}} allows setting which pieces of text are displayed in the wikilink. It sets the ''label'' in the link: <code><nowiki>[[targetpage|label]]</nowiki></code>
{|class=wikitable width="100%"
+
 
 +
For example, the ship's article is entered as <code><nowiki>{{ship|HMS|Illustrious|R06}}</nowiki></code>, by default showing as {{ship|HMS|Illustrious|R06}}.
 +
 
 +
But in your article, the hull number (disambiguator) may not be needed to show. In that case, add {{para|4|2}}, and the result is:
 +
:<code><nowiki>{{ship</nowiki>|HMS|Illustrious|R06<span style="background:yellow;">|2</span>}} <code><nowiki>[[HMS Illustrious (R06)|''Illustrious'']]</nowiki></code> </code> &rarr; {{ship|HMS|Illustrious|R06|2}}
 +
 
 +
The options are:
 +
{|class=wikitable width=100%
 
! Value
 
! Value
 
! Parameter(s)<br>displayed
 
! Parameter(s)<br>displayed
Line 40: Line 47:
 
! Equivalent wikicode
 
! Equivalent wikicode
 
! Final result
 
! Final result
 +
|-same as default
 +
! None
 +
| style="text-align:center;" | prefix, name, ID
 +
| colspan=2 | <nowiki>{{ship|HMS|Illustrious|R06}}</nowiki>
 +
| <nowiki>[[HMS Illustrious (R06)|HMS ''Illustrious'' (R06)]]</nowiki>
 +
| {{ship|HMS|Illustrious|R06}}
 
|-
 
|-
 
! 1
 
! 1
| style="text-align:center;" | 3rd
+
| style="text-align:center;" | ID
| colspan=2 | <nowiki>{{HMS|Illustrious|R06|1}}</nowiki>
+
| colspan=2 | <nowiki>{{ship|HMS|Illustrious|R06|1}}</nowiki>
 
| <nowiki>[[HMS Illustrious (R06)|R06]]</nowiki>
 
| <nowiki>[[HMS Illustrious (R06)|R06]]</nowiki>
| {{HMS|Illustrious|R06|1}}
+
| {{ship|HMS|Illustrious|R06|1}}
 
|-
 
|-
 
! 2
 
! 2
| style="text-align:center;" | 2nd
+
| style="text-align:center;" | name
| colspan=2 | <nowiki>{{HMS|Illustrious|R06|2}</nowiki>}
+
| colspan=2 | <nowiki>{{ship|HMS|Illustrious|R06|2}}</nowiki>
| <nowiki>[[HMS Illustrious (R06)|''Illustrious'']]</nowiki>
+
| <nowiki>[[HMS Illustrious (R06)|''Illustrious'']]</nowiki>
| {{HMS|Illustrious|R06|2}}
+
| {{ship|HMS|Illustrious|R06|2}}
 
|-
 
|-
 
! 3
 
! 3
| style="text-align:center;" | 2nd, 3rd
+
| style="text-align:center;" | name, ID
| colspan=2 | <nowiki>{{HMS|Illustrious|R06|3}}</nowiki>
+
| colspan=2 | <nowiki>{{ship|HMS|Illustrious|R06|3}}</nowiki>
| <nowiki>[[HMS Illustrious (R06)|''Illustrious'' R06]]</nowiki>
+
| <nowiki>[[HMS Illustrious (R06)|''Illustrious'' (R06)]]</nowiki>
| {{HMS|Illustrious|R06|3}}
+
| {{ship|HMS|Illustrious|R06|3}}
 
|-
 
|-
 
! 4
 
! 4
| style="text-align:center;" | invalid result
+
| style="text-align:center;" | ''same as default''
| colspan=2 | <nowiki>{{HMS|Illustrious|R06|4}}</nowiki>
+
| colspan=2 | <nowiki>{{ship|HMS|Illustrious|R06|4}}</nowiki>
| <nowiki>[[HMS Illustrious (R06)|Invalid Optional Parameter]]</nowiki>
+
| <nowiki>[[HMS Illustrious (R06)|HMS ''Illustrious'' (R06)]]</nowiki>
| {{HMS|Illustrious|R06|4}}
+
| {{ship|HMS|Illustrious|R06|4}}
 
|-
 
|-
 
! 5
 
! 5
| style="text-align:center;" | 1st, 3rd
+
| style="text-align:center;" | prefix, ID
| colspan=2 | <nowiki>{{HMS|Illustrious|R06|5}}</nowiki>
+
| colspan=2 | <nowiki>{{ship|HMS|Illustrious|R06|5}}</nowiki>
| <nowiki>[[HMS Illustrious (R06)|HMS R06]]</nowiki>
+
| <nowiki>[[HMS Illustrious (R06)|HMS ''R06'']]</nowiki>
| {{HMS|Illustrious|R06|5}}
+
| {{ship|HMS|Illustrious|R06|5}}
 
|-
 
|-
 
! 6
 
! 6
| style="text-align:center;" | 1st, 2nd
+
| style="text-align:center;" | prefix, name
| colspan=2 | <nowiki>{{HMS|Illustrious|R06|6}}</nowiki>
+
| colspan=2 | <nowiki>{{ship|HMS|Illustrious|R06|6}}</nowiki>
 
| <nowiki>[[HMS Illustrious (R06)|HMS ''Illustrious'']]</nowiki>
 
| <nowiki>[[HMS Illustrious (R06)|HMS ''Illustrious'']]</nowiki>
| {{HMS|Illustrious|R06|6}}
+
| {{ship|HMS|Illustrious|R06|6}}
|-
+
|}
!
 
| style="text-align:center;" | 2nd<br><small>(no 3rd)</small>
 
| <nowiki>{{HMS|Victory|3=2}}</nowiki>
 
| <nowiki>Alternate usage: {{HMS|Victory||2}}</nowiki>
 
| <nowiki>[[HMS Victory|''Victory'']]</nowiki>
 
| {{HMS|Victory||2}}
 
|}
 
''N.B.'':  Be careful with the third parameter if not using the second parameter. In the ''Victory'' example above, the "|3=2" means set the third parameter to a value of two, while the alternate syntax shows using a pair of pipes, "||2", to position the value two in the third parameter position.
 
 
 
Using an optional display control parameter value of 6 yields the same results as using {{tl|warship}} to create the same link and text, but saving, coincidentally, 6 characters while editing.
 
 
 
  <nowiki>{{HMS|Illustrious|R06|6}} yields the same results as {{warship|HMS|Illustrious|R06}}</nowiki>
 
  
 
==TemplataData section==
 
==TemplataData section==

Revision as of 01:54, 11 March 2018

Usage

This is a typing short cut for linking to Royal Navy ship articles named in the format "HMS Gloucester (D96)". Since Ship names are italicized in article text, and editors often don't want to include the pennant number, linking to them in the usual manner means typing everything twice, such as [[HMS Gloucester (D96)|HMS ''Gloucester'']]. This template halves that to {{HMS|Gloucester|D96|6}}.

Formal usage

{{HMS|Ship Name}}
{{HMS|Ship Name|ID}}, where ID can be the hull number, launch year, or pennant number, as specified in the article title.

Examples

Template usage Equivalent wikicode Final result
{{HMS|Illustrious|R06}} [[HMS Illustrious (R06)|HMS ''Illustrious'' (R06)]] HMS Illustrious (R06)
{{HMS|Raisonnable|1768}} [[HMS Raisonnable (1768)|HMS ''Raisonnable'' (1768)]] HMS Raisonnable (1768)
{{HMS|Victory}} [[HMS Victory|HMS ''Victory'']] HMS Victory

Last example could be used to link to ship index (disambiguation) page

Format options parameter

A fourth, unnamed parameter |4= allows setting which pieces of text are displayed in the wikilink. It sets the label in the link: [[targetpage|label]]

For example, the ship's article is entered as {{ship|HMS|Illustrious|R06}}, by default showing as HMS Illustrious (R06).

But in your article, the hull number (disambiguator) may not be needed to show. In that case, add |4=2, and the result is:

{{ship|HMS|Illustrious|R06|2}} [[HMS Illustrious (R06)|''Illustrious'']] Illustrious

The options are:

Value Parameter(s)
displayed
Example Equivalent wikicode Final result
None prefix, name, ID {{ship|HMS|Illustrious|R06}} [[HMS Illustrious (R06)|HMS ''Illustrious'' (R06)]] HMS Illustrious (R06)
1 ID {{ship|HMS|Illustrious|R06|1}} [[HMS Illustrious (R06)|R06]] R06
2 name {{ship|HMS|Illustrious|R06|2}} [[HMS Illustrious (R06)|''Illustrious'']] Illustrious
3 name, ID {{ship|HMS|Illustrious|R06|3}} [[HMS Illustrious (R06)|''Illustrious'' (R06)]] Illustrious (R06)
4 same as default {{ship|HMS|Illustrious|R06|4}} [[HMS Illustrious (R06)|HMS ''Illustrious'' (R06)]] HMS Illustrious (R06)
5 prefix, ID {{ship|HMS|Illustrious|R06|5}} [[HMS Illustrious (R06)|HMS ''R06'']] HMS R06
6 prefix, name {{ship|HMS|Illustrious|R06|6}} [[HMS Illustrious (R06)|HMS ''Illustrious'']] HMS Illustrious

TemplataData section

Syntax error in JSON.

See also

Template:WPSHIPS shortcut templates