Template:Resource link: Difference between revisions

From Against the Storm Official Wiki
(improved the template documentation; renamed product to resource for consistency)
(Updated resource link method invoke. Also improved documentation)
Line 1: Line 1:
<includeonly>{{#invoke:ResourceLink|renderLink|resource={{{1|{{{resource|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</includeonly><noinclude>
<includeonly>{{#invoke:ResourceLink|resourceLink|resource={{{1|{{{resource|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</includeonly><noinclude>


<code><nowiki>{{#invoke:ResourceLink|renderLink|resource={{{1|{{{resource|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</nowiki></code>
'''Resource_link''' is a template creates links to resources (or goods) on the wiki and includes an icon for improved recognition. Reuses standardizes icon size templates for consistency.


The [[Template:rl]] is a shortcut to this template.


This template is used like this: <code><nowiki>{{Resource link|resource|iconsize}}</nowiki></code>
== Overview ==


This template should be used liberally across the wiki, wherever the names of goods are mentioned in paragraphs or in tables. The accompanying icons will help skimming for expert players and orientation for new players.


This template calls <code>renderLink</code> in '''Module:ResourceLink''' to make icons and short wiki links to a resource's page. The icon can be small, huge, or in between. The small icon is sized appropriately to fit well into in-line text.
For in-paragraph display, which is presumed to be the most common utilization, the default icon size is <code>small</code>, or {{ImgS}} from [[Template:ImgS]]. For use in tables where more spacing between lines doesn't hurt readability or aesthetics, it is recommended to use <code>med</code>, which will increase the size of the icons to {{ImgM}} (from [[Template:ImgM]]).


This template standardizes the display of icons and resourcesthroughout the wiki and simplifies the amount of writing that is necessary when adding new content pages.
Use your judgment when writing content. The first mention of a resource in a paragraph should probably be done with this template. But you may find that paragraphs densely mentioning resources become harder not easier to read. You may decide that after the first mention of the resource, it's better for subsequent references to be in plain text or with this template but without an icon.


== Usage ==
<pre>
{{Resource link|resource|iconsize}}
</pre>
== Parameters ==
Only the first parameter, <code>resource</code> is required, and it must be spelled correctly to match the in-game name of the resource or good. The other parameter is optional but improve this template's applicability to more instances of its use. You may include or omit any parameters' names.
{|class="wikitable"
|-
! Parameter !! Type !! Description
|-
| resource || string || '''Required.''' The in-game name of the good whose page you want to link to and whose icon you want to display.
|-
| iconsize || string || One of the following values to indicate the desired size of the icon:<br />
<table><tr><td>
* <code>none</code>
* <code>small</code>
* <code>med</code>
* <code>large</code>
* <code>huge</code>
</td><td>
which will prevent an icon from displaying<br />
which sizes the icon to {{ImgS}} from [[Template:ImgS]], '''default'''<br />
which sizes the icon to {{ImgM}} from [[Template:ImgM]]<br />
which sizes the icon to {{ImgL}} from [[Template:ImgL]]<br />
which sizes the icon to {{ImgH}} from [[Template:ImgH]]
</td></tr></table>
|}
== Errors ==
When the template is called without a resource name, the template reminds you that it is required.
'''Example:'''
<pre>
{{Resource link}}
</pre>


A shortcut template also exists <code><nowiki>{{rl}}</nowiki></code>, to make writing a page with many resource links a little easier.
Yields:


'''{{Resource link}}'''


== Usage ==
When providing the name of a good, it is important that it is spelled correctly, including any punctuation or spaces. Otherwise, you will see an error message:


Use the name of the resource name as it appears in the game. (The background code performs some normalization, but only to catch small mistakes in spacing or apostrophes.)
'''Example:'''


Giving the template a resource name will result in a text-sized icon and a link to the wiki page for that resource. This is useful in-line with text in paragraphs, where resource icons can still be recognized.
Broken: <code><nowiki>{{Resource link|TrainingGear}}</nowiki></code>


'''{{Resource link|TrainingGear}}'''


Telling the template what size to make the icon allows the icon to be larger and more distinguishable. This is useful when creating tables where a larger resource icon increases recognition. IF the resource is not known to the data modules behind the scenes, an error will appear.
Fixed: <code><nowiki>{{Resource link|Training Gear}}</nowiki></code>


The default is a small icon, for use in-line with text. You can also use <code>med</code>, <code>large</code>, <code>huge</code>, or write <code>small</code> explicitly, to describe the desired size of the icon, as you can see below.
{{Resource link|Training Gear}}


== Additional Examples and Errors ==


Here are ways to call the template and the expected result:
Here are ways to call the template and the expected result:


{| class="wikitable"
{| class="wikitable"
! Argument !! Examples !! Expected outcome
! Parameters !! Examples !! Expected outcome
|-
|-
| None
| None
|style="white-space: nowrap"| <code><nowiki>{{Resource link}}</nowiki></code>
| <code><nowiki>{{Resource link}}</nowiki></code><br />or <code><nowiki>{{rl}}</nowiki></code>
| An error.
| An error.
|-
|-
| Resource name or <br /> Resource name and a "small" icon size
| resource only
|style="white-space: nowrap"| <code><nowiki>{{Resource link|Biscuits}}</nowiki></code> <br /> <code><nowiki>{{Resource link|Crystalized Dew|small}}</nowiki></code>
| <code><nowiki>{{Resource link|Biscuits}}</nowiki></code>
| A small, text-sized icon and link to the wiki page for the resource.
|rowspan="2"| A small, text-sized icon and link, best for within paragraphs.
|-
|-
| Resource name and a "med" icon size
|rowspan="4"| resource and iconsize
|style="white-space: nowrap"| <code><nowiki>{{Resource link|Biscuits|med}}</nowiki></code> <br /> <code><nowiki>{{Resource link|Training Gear|med}}</nowiki></code>
| <code><nowiki>{{rl|Crystalized Dew|small}}</nowiki></code>
| A fair-sized resource icon and a link to its wiki page.
|-
|-
| Resource name and a "large" icon size
| <code><nowiki>{{rl|Training Gear|med}}</nowiki></code>
|style="white-space: nowrap"| <code><nowiki>{{Resource link|Biscuits|large}}</nowiki></code> <br /> <code><nowiki>{{Resource link|Waterskins|large}}</nowiki></code>
| A moderately-sized resource icon and a link, best in dense tables.
| A large resource icon and a link to its wiki page.
|-
|-
| Resource name and a "huge" icon size
| <code><nowiki>{{rl|Flour|large}}</nowiki></code>
|style="white-space: nowrap"| <code><nowiki>{{Resource link|Biscuits|huge}}</nowiki></code> <br /> <code><nowiki>{{Resource link|Pack of Trade Goods|huge}}</nowiki></code>
| A large resource icon and a link, best as featured items within tables.
| A very large resource icon and a link to its wiki page.
|-
| <code><nowiki>{{rl|Pack of Trade Goods|huge}}</nowiki></code>
| A very large resource icon and a link, in case you every need one this big.
|}
|}


The following are generated by calling the template.


== Examples ==
1 <code><nowiki>{{Resource link|Biscuits|none}}</nowiki></code> yields:


The following are generated by calling the template, as shown in the examples in the table above.
{{Resource link|Biscuits|none}}


2. <code><nowiki>{{Resource link|Biscuits|small}}</nowiki></code> yields:


1. <code><nowiki>{{Resource link|Biscuits}}</nowiki></code> yields:
{{Resource link|Biscuits|small}}


{{Resource link|Biscuits}}
3. <code><nowiki>{{Resource link|Biscuits|med}}</nowiki></code> yields:
 
 
2. <code><nowiki>{{Resource link|Biscuits|med}}</nowiki></code> yields:


{{Resource link|Biscuits|med}}
{{Resource link|Biscuits|med}}


 
4. <code><nowiki>{{Resource link|Biscuits|large}}</nowiki></code> yields:
3. <code><nowiki>{{Resource link|Biscuits|large}}</nowiki></code> yields:


{{Resource link|Biscuits|large}}
{{Resource link|Biscuits|large}}


 
5. <code><nowiki>{{Resource link|Biscuits|huge}}</nowiki></code> yields:
4. <code><nowiki>{{Resource link|Biscuits|huge}}</nowiki></code> yields:


{{Resource link|Biscuits|huge}}
{{Resource link|Biscuits|huge}}


The following are additional incorrect usages of the template:


The following are error messages generated by calling the template incorrectly.
6. With no resource but an icon size, <code><nowiki>{{Resource link||large}}</nowiki></code> yields:
 
 
5. With no arguments, <code><nowiki>{{Resource link}}</nowiki></code> yields:
 
'''{{Resource link}}'''
 
 
6. With the name of something that doesn't exist in the game, <code><nowiki>{{Resource link|Biscits}}</nowiki></code> yields:
 
'''{{Resource link|Biscits}}'''
 
 
7. With no resource but an icon size, <code><nowiki>{{Resource link||large}}</nowiki></code> yields:


'''{{Resource link||large}}'''
'''{{Resource link||large}}'''


Finally, providing an icon size that is not recognized does not break the template. There is a default icon size instead of returning an error.


Finally, providing an icon size that is not recognized does not break the template.
9. With a valid resource but invalid icon size, <code><nowiki>{{Resource link|Biscuits|gigantic}}</nowiki></code> yields:
 
 
8. With a valid resource but invalid icon size, <code><nowiki>{{Resource link|Biscuits|gigantic}}</nowiki></code> yields:


{{Resource link|Biscuits|gigantic}}</noinclude>
{{Resource link|Biscuits|gigantic}}</noinclude>

Revision as of 22:36, 18 November 2023


Resource_link is a template creates links to resources (or goods) on the wiki and includes an icon for improved recognition. Reuses standardizes icon size templates for consistency.

The Template:rl is a shortcut to this template.

Overview

This template should be used liberally across the wiki, wherever the names of goods are mentioned in paragraphs or in tables. The accompanying icons will help skimming for expert players and orientation for new players.

For in-paragraph display, which is presumed to be the most common utilization, the default icon size is small, or x18px from Template:ImgS. For use in tables where more spacing between lines doesn't hurt readability or aesthetics, it is recommended to use med, which will increase the size of the icons to x30px (from Template:ImgM).

Use your judgment when writing content. The first mention of a resource in a paragraph should probably be done with this template. But you may find that paragraphs densely mentioning resources become harder not easier to read. You may decide that after the first mention of the resource, it's better for subsequent references to be in plain text or with this template but without an icon.

Usage

{{Resource link|resource|iconsize}}

Parameters

Only the first parameter, resource is required, and it must be spelled correctly to match the in-game name of the resource or good. The other parameter is optional but improve this template's applicability to more instances of its use. You may include or omit any parameters' names.

Parameter Type Description
resource string Required. The in-game name of the good whose page you want to link to and whose icon you want to display.
iconsize string One of the following values to indicate the desired size of the icon:
  • none
  • small
  • med
  • large
  • huge

which will prevent an icon from displaying
which sizes the icon to x18px from Template:ImgS, default
which sizes the icon to x30px from Template:ImgM
which sizes the icon to x60px from Template:ImgL
which sizes the icon to x84px from Template:ImgH

Errors

When the template is called without a resource name, the template reminds you that it is required.

Example:

{{Resource link}}

Yields:

The Resource_link template requires the name of a resource.

When providing the name of a good, it is important that it is spelled correctly, including any punctuation or spaces. Otherwise, you will see an error message:

Example:

Broken: {{Resource link|TrainingGear}}

No goods found with that name: TrainingGear.

Fixed: {{Resource link|Training Gear}}

Training Gear Training Gear

Additional Examples and Errors

Here are ways to call the template and the expected result:

Parameters Examples Expected outcome
None {{Resource link}}
or {{rl}}
An error.
resource only {{Resource link|Biscuits}} A small, text-sized icon and link, best for within paragraphs.
resource and iconsize {{rl|Crystalized Dew|small}}
{{rl|Training Gear|med}} A moderately-sized resource icon and a link, best in dense tables.
{{rl|Flour|large}} A large resource icon and a link, best as featured items within tables.
{{rl|Pack of Trade Goods|huge}} A very large resource icon and a link, in case you every need one this big.

The following are generated by calling the template.

1 {{Resource link|Biscuits|none}} yields:

Biscuits

2. {{Resource link|Biscuits|small}} yields:

Biscuits Biscuits

3. {{Resource link|Biscuits|med}} yields:

Biscuits Biscuits

4. {{Resource link|Biscuits|large}} yields:

Biscuits Biscuits

5. {{Resource link|Biscuits|huge}} yields:

Biscuits Biscuits

The following are additional incorrect usages of the template:

6. With no resource but an icon size, {{Resource link||large}} yields:

The Resource_link template requires the name of a resource.

Finally, providing an icon size that is not recognized does not break the template. There is a default icon size instead of returning an error.

9. With a valid resource but invalid icon size, {{Resource link|Biscuits|gigantic}} yields:

Biscuits Biscuits