Template:Resource link: Difference between revisions
(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| | <includeonly>{{#invoke:ResourceLink|resourceLink|resource={{{1|{{{resource|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</includeonly><noinclude> | ||
'''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 <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]]). | |||
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> | |||
Yields: | |||
'''{{Resource link}}''' | |||
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: <code><nowiki>{{Resource link|TrainingGear}}</nowiki></code> | |||
'''{{Resource link|TrainingGear}}''' | |||
Fixed: <code><nowiki>{{Resource link|Training Gear}}</nowiki></code> | |||
{{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" | ||
! | ! Parameters !! Examples !! Expected outcome | ||
|- | |- | ||
| None | | None | ||
| <code><nowiki>{{Resource link}}</nowiki></code><br />or <code><nowiki>{{rl}}</nowiki></code> | |||
| An error. | | An error. | ||
|- | |- | ||
| | | resource only | ||
| <code><nowiki>{{Resource link|Biscuits}}</nowiki></code> | |||
| A small, text-sized icon and link | |rowspan="2"| A small, text-sized icon and link, best for within paragraphs. | ||
|- | |- | ||
| | |rowspan="4"| resource and iconsize | ||
| <code><nowiki>{{rl|Crystalized Dew|small}}</nowiki></code> | |||
|- | |- | ||
| <code><nowiki>{{rl|Training Gear|med}}</nowiki></code> | |||
| A moderately-sized resource icon and a link, best in dense tables. | |||
| A | |||
|- | |- | ||
| <code><nowiki>{{rl|Flour|large}}</nowiki></code> | |||
| A large resource icon and a link, best as featured items within tables. | |||
| A very large resource icon and a link | |- | ||
| <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. | |||
1 <code><nowiki>{{Resource link|Biscuits|none}}</nowiki></code> yields: | |||
{{Resource link|Biscuits|none}} | |||
2. <code><nowiki>{{Resource link|Biscuits|small}}</nowiki></code> yields: | |||
{{Resource link|Biscuits|small}} | |||
3. <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: | |||
{{Resource link|Biscuits|large}} | {{Resource link|Biscuits|large}} | ||
5. <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: | |||
6. With no resource but an icon size, <code><nowiki>{{Resource link||large}}</nowiki></code> yields: | |||
6 | |||
'''{{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. | |||
9. 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 x16px 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:
|
Errors
When the template is called without a resource name, the template reminds you that it is required.
Example:
{{Resource link}}
Yields:
Script error: The function "resourceLink" does not exist.
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}}
Script error: The function "resourceLink" does not exist.
Fixed: {{Resource link|Training Gear}}
Script error: The function "resourceLink" does not exist.
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:
Script error: The function "resourceLink" does not exist.
2. {{Resource link|Biscuits|small}}
yields:
Script error: The function "resourceLink" does not exist.
3. {{Resource link|Biscuits|med}}
yields:
Script error: The function "resourceLink" does not exist.
4. {{Resource link|Biscuits|large}}
yields:
Script error: The function "resourceLink" does not exist.
5. {{Resource link|Biscuits|huge}}
yields:
Script error: The function "resourceLink" does not exist.
The following are additional incorrect usages of the template:
6. With no resource but an icon size, {{Resource link||large}}
yields:
Script error: The function "resourceLink" does not exist.
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:
Script error: The function "resourceLink" does not exist.