Template:shortcut

From Homestar Runner Wiki

(Difference between revisions)
Jump to: navigation, search
(adding more desc; how's that?)
(make first parameter optional (although it's still highly recommended); pluralize "Shortcut" when appropriate)
Line 1: Line 1:
<div id="shortcut" style="border: 1px dashed blue; margin: 0em 1em 0em 1em; text-align: center; padding:5px; float: right; clear: both;">
<div id="shortcut" style="border: 1px dashed blue; margin: 0em 1em 0em 1em; text-align: center; padding:5px; float: right; clear: both;">
-
Shortcut:<br>[[HRW:{{{1}}}]]{{#if:{{{2|}}}|<br>[[HRW:{{{2}}}]]|}}{{#if:{{{3|}}}|<br>{{{3}}}|}}</div><noinclude>
+
Shortcut{{#ifeq:{{{plural}}}|false||{{#ifexpr: ( ( {{#if:{{{1|}}}|1|0}} + {{#if:{{{2|}}}|1|0}} + {{#if:{{{3|}}}|1|0}} ) > 1 ) or {{#if:{{{plural|}}}|1|0}}|s||}}}}:{{#if:{{{1|}}}|<br>[[HRW:{{{1}}}]]|}}{{#if:{{{2|}}}|<br>[[HRW:{{{2}}}]]|}}{{#if:{{{3|}}}|<br>{{{3}}}|}}</div><noinclude>
===Usage:===
===Usage:===
-
When linking to a shortcut in the '''HRW''' Pseudo-namespace, simply enter the target name (without the namespace) as a template parameter:
+
When linking to a shortcut in the '''HRW''' pseudo-namespace, simply enter the target name (without the namespace) as a template parameter:
-
*<code><nowiki>{{shortcut|SHORTCUT1}}</nowiki></code> &mdash; automatically links to '''HRW:SHORTCUT1''' (''Note that the '''HRW:''' pseudo-namespace is automatically added'')
+
:<code><nowiki>{{shortcut|SHORTCUT1}}</nowiki></code> &mdash; automatically links to '''HRW:SHORTCUT1''' ''(Note that the '''HRW:''' pseudo-namespace is automatically added)''
-
*:or
+
::or
-
*<code><nowiki>{{shortcut|SHORTCUT1|SHORTCUT2}}</nowiki></code> &mdash; automatically links to '''HRW:SHORTCUT1''' and '''HRW:SHORTCUT2'''
+
:<code><nowiki>{{shortcut|SHORTCUT1|SHORTCUT2}}</nowiki></code> &mdash; automatically links to '''HRW:SHORTCUT1''' and '''HRW:SHORTCUT2'''
-
*:or
+
::or
-
*<code><nowiki>{{shortcut|SHORTCUT1|SHORTCUT2|[[HRW:SHORTCUT3]]}}</nowiki></code> &mdash; same as above, except the third parameter requires extra formatting since it's a free-for-all. As shown, it links to '''HRW:SHORTCUT3''', but you could string any number of extra links in the form:  
+
:<code><nowiki>{{shortcut|SHORTCUT1|SHORTCUT2|[[HRW:SHORTCUT3]]}}</nowiki></code> &mdash; same as above, except the third parameter requires extra formatting since it's a free-for-all. As shown, it links to '''HRW:SHORTCUT3''', but you could string any number of extra links in the form:  
-
**<code><nowiki>[[HRW:SHORTCUT3]]<br>[[HRW:SHORTCUT4]]</nowiki></code> &mdash; adds links to '''HRW:SHORTCUT3''' and '''HRW:SHORTCUT4'''
+
::<code><nowiki>[[HRW:SHORTCUT3]]<br>[[HRW:SHORTCUT4]]</nowiki></code> &mdash; adds links to '''HRW:SHORTCUT3''' and '''HRW:SHORTCUT4'''
-
**<code><nowiki>[[SHORTCUT3]]<br>[[HRWiki:SHORTCUT4]]</nowiki></code> &mdash; adds links to '''SHORTCUT3''' and '''HRWiki:SHORTCUT4'''
+
::<code><nowiki>[[SHORTCUT3]]<br>[[HRWiki:SHORTCUT4]]</nowiki></code> &mdash; adds links to '''SHORTCUT3''' and '''HRWiki:SHORTCUT4'''
-
This last parameter is used when you need to link to '''non-HRW''' pages or the page containst more than two shortcuts.  You may link to an '''HRW''' shortcut page and a '''non-HRW''' page, but you must do so with care:
+
This last parameter is used when you need to link to '''non-HRW''' pages or the page contains more than two shortcuts.  You may link to an '''HRW''' shortcut page and a '''non-HRW''' page like so (note in the following example that the second parameter is empty):
-
*<code><nowiki>{{shortcut|SHORTCUT1||[[SHORTCUT3]]}}</nowiki></code> &mdash; will link to '''HRW:SHORTCUT1''' and '''SHORTCUT3''' respectively.
+
:<code><nowiki>{{shortcut|SHORTCUT1||[[SHORTCUT3]]}}</nowiki></code> &mdash; will link to '''HRW:SHORTCUT1''' and '''SHORTCUT3''' respectively
-
However, you '''must''' link to at least one page in the '''HRW''' namespace.
+
If there are not currently any '''HRW''' namespace links, you can skip straight to the third parameter (although creating at least one '''HRW''' link is strongly preferred).
-
</noinclude><noinclude>
+
:<code><nowiki>{{shortcut|3=[[SHORTCUT]]}}</nowiki></code> &mdash; will link to '''SHORTCUT'''
 +
The word "Shortcut" is automatically made plural if it can tell that there is more than one link. To set the value manually, set <code>plural=true</code> or <code>plural=false</code>:
 +
:<code><nowiki>{{shortcut|3=[[SHORTCUT1]]<br>[[SHORTCUT2]]|plural=true}}</nowiki></code>
[[Category:Internal link templates|{{PAGENAME}}]]
[[Category:Internal link templates|{{PAGENAME}}]]
</noinclude>
</noinclude>

Revision as of 02:59, 28 April 2007

Shortcut:

Usage:

When linking to a shortcut in the HRW pseudo-namespace, simply enter the target name (without the namespace) as a template parameter:

{{shortcut|SHORTCUT1}} — automatically links to HRW:SHORTCUT1 (Note that the HRW: pseudo-namespace is automatically added)
or
{{shortcut|SHORTCUT1|SHORTCUT2}} — automatically links to HRW:SHORTCUT1 and HRW:SHORTCUT2
or
{{shortcut|SHORTCUT1|SHORTCUT2|[[HRW:SHORTCUT3]]}} — same as above, except the third parameter requires extra formatting since it's a free-for-all. As shown, it links to HRW:SHORTCUT3, but you could string any number of extra links in the form:
[[HRW:SHORTCUT3]]<br>[[HRW:SHORTCUT4]] — adds links to HRW:SHORTCUT3 and HRW:SHORTCUT4
[[SHORTCUT3]]<br>[[HRWiki:SHORTCUT4]] — adds links to SHORTCUT3 and HRWiki:SHORTCUT4

This last parameter is used when you need to link to non-HRW pages or the page contains more than two shortcuts. You may link to an HRW shortcut page and a non-HRW page like so (note in the following example that the second parameter is empty):

{{shortcut|SHORTCUT1||[[SHORTCUT3]]}} — will link to HRW:SHORTCUT1 and SHORTCUT3 respectively

If there are not currently any HRW namespace links, you can skip straight to the third parameter (although creating at least one HRW link is strongly preferred).

{{shortcut|3=[[SHORTCUT]]}} — will link to SHORTCUT

The word "Shortcut" is automatically made plural if it can tell that there is more than one link. To set the value manually, set plural=true or plural=false:

{{shortcut|3=[[SHORTCUT1]]<br>[[SHORTCUT2]]|plural=true}}
Personal tools