Template:Resource link: Difference between revisions

From Against the Storm Official Wiki
(changed resource example to something that's not a redlink)
(improved the template documentation; renamed product to resource for consistency)
Line 1: Line 1:
{{#invoke:ResourceLink|renderLink|resource={{{1|}}}|iconsize={{{2|}}}}}<noinclude>
<includeonly>{{#invoke:ResourceLink|renderLink|resource={{{1|{{{resource|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</includeonly><noinclude>


This template takes a resource name and turns it into an image followed by a link to the resource. Use the in-game name of the resource (with or without spaces should work, as the background code contains some deconfliction). The default is the icon size is <code><nowiki>{{ImgS}}</nowiki></code>, or <code>{{ImgS}}</code>, for use in-line with text. You can also use <code>med</code>, <code>large</code>, or <code>huge</code>, as you can see below.
<code><nowiki>{{#invoke:ResourceLink|renderLink|resource={{{1|{{{resource|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</nowiki></code>


For example:


<pre>{{Resource_link|Pickled Goods}}
This template is used like this: <code><nowiki>{{Resource link|resource|iconsize}}</nowiki></code>
{{Resource_link|Pickled Goods|med}}
{{Resource_link|Pickled Goods|large}}
{{Resource_link|Pickled Goods|huge}}</pre>


{{Resource_link|Pickled Goods}}


{{Resource_link|Pickled Goods|med}}
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.


{{Resource_link|Pickled Goods|large}}
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.


{{Resource_link|Pickled Goods|huge}}</noinclude>
 
A shortcut template also exists <code><nowiki>{{rl}}</nowiki></code>, to make writing a page with many resource links a little easier.
 
 
== Usage ==
 
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.)
 
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.
 
 
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.
 
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.
 
 
Here are ways to call the template and the expected result:
 
{| class="wikitable"
! Argument !! Examples !! Expected outcome
|-
| None
|style="white-space: nowrap"| <code><nowiki>{{Resource link}}</nowiki></code>
| An error.
|-
| Resource name or <br /> Resource name and a "small" icon size
|style="white-space: nowrap"| <code><nowiki>{{Resource link|Biscuits}}</nowiki></code> <br /> <code><nowiki>{{Resource link|Crystalized Dew|small}}</nowiki></code>
| A small, text-sized icon and link to the wiki page for the resource.
|-
| Resource name and a "med" icon size
|style="white-space: nowrap"| <code><nowiki>{{Resource link|Biscuits|med}}</nowiki></code> <br /> <code><nowiki>{{Resource link|Training Gear|med}}</nowiki></code>
| A fair-sized resource icon and a link to its wiki page.
|-
| Resource name and a "large" icon size
|style="white-space: nowrap"| <code><nowiki>{{Resource link|Biscuits|large}}</nowiki></code> <br /> <code><nowiki>{{Resource link|Waterskins|large}}</nowiki></code>
| A large resource icon and a link to its wiki page.
|-
| Resource name and a "huge" icon size
|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 very large resource icon and a link to its wiki page.
|}
 
 
== Examples ==
 
The following are generated by calling the template, as shown in the examples in the table above.
 
 
1. <code><nowiki>{{Resource link|Biscuits}}</nowiki></code> yields:
 
{{Resource link|Biscuits}}
 
 
2. <code><nowiki>{{Resource link|Biscuits|med}}</nowiki></code> yields:
 
{{Resource link|Biscuits|med}}
 
 
3. <code><nowiki>{{Resource link|Biscuits|large}}</nowiki></code> yields:
 
{{Resource link|Biscuits|large}}
 
 
4. <code><nowiki>{{Resource link|Biscuits|huge}}</nowiki></code> yields:
 
{{Resource link|Biscuits|huge}}
 
 
The following are error messages generated by calling the template incorrectly.
 
 
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}}'''
 
 
Finally, providing an icon size that is not recognized does not break the template.
 
 
8. With a valid resource but invalid icon size, <code><nowiki>{{Resource link|Biscuits|gigantic}}</nowiki></code> yields:
 
{{Resource link|Biscuits|gigantic}}</noinclude>

Revision as of 04:16, 14 February 2023


{{#invoke:ResourceLink|renderLink|resource={{{1|{{{resource|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}


This template is used like this: {{Resource link|resource|iconsize}}


This template calls renderLink 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.

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.


A shortcut template also exists {{rl}}, to make writing a page with many resource links a little easier.


Usage

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.)

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.


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.

The default is a small icon, for use in-line with text. You can also use med, large, huge, or write small explicitly, to describe the desired size of the icon, as you can see below.


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

Argument Examples Expected outcome
None {{Resource link}} An error.
Resource name or
Resource name and a "small" icon size
{{Resource link|Biscuits}}
{{Resource link|Crystalized Dew|small}}
A small, text-sized icon and link to the wiki page for the resource.
Resource name and a "med" icon size {{Resource link|Biscuits|med}}
{{Resource link|Training Gear|med}}
A fair-sized resource icon and a link to its wiki page.
Resource name and a "large" icon size {{Resource link|Biscuits|large}}
{{Resource link|Waterskins|large}}
A large resource icon and a link to its wiki page.
Resource name and a "huge" icon size {{Resource link|Biscuits|huge}}
{{Resource link|Pack of Trade Goods|huge}}
A very large resource icon and a link to its wiki page.


Examples

The following are generated by calling the template, as shown in the examples in the table above.


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

Script error: The function "renderLink" does not exist.


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

Script error: The function "renderLink" does not exist.


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

Script error: The function "renderLink" does not exist.


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

Script error: The function "renderLink" does not exist.


The following are error messages generated by calling the template incorrectly.


5. With no arguments, {{Resource link}} yields:

Script error: The function "renderLink" does not exist.


6. With the name of something that doesn't exist in the game, {{Resource link|Biscits}} yields:

Script error: The function "renderLink" does not exist.


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

Script error: The function "renderLink" does not exist.


Finally, providing an icon size that is not recognized does not break the template.


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

Script error: The function "renderLink" does not exist.